00001
00002
00003 #ifndef _GCONFMM_CLIENT_H
00004 #define _GCONFMM_CLIENT_H
00005
00006
00007 #include <glibmm.h>
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <gconf/gconf-client.h>
00032
00033 #include <glibmm/object.h>
00034
00035 #include <glibmm/error.h>
00036 #include <gconfmm/value.h>
00037 #include <gconfmm/callback.h>
00038 #include <gconfmm/entry.h>
00039 #include <gconfmm/schema.h>
00040 #include <gconfmm/setinterface.h>
00041 #include <gconfmm/changeset.h>
00042
00043
00044 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00045 typedef struct _GConfClient GConfClient;
00046 typedef struct _GConfClientClass GConfClientClass;
00047 #endif
00048
00049
00050 namespace Gnome
00051 {
00052
00053 namespace Conf
00054 { class Client_Class; }
00055
00056 }
00057 namespace Gnome
00058 {
00059 namespace Conf
00060 {
00061
00067 enum ClientErrorHandlingMode
00068 {
00069 CLIENT_HANDLE_NONE,
00070 CLIENT_HANDLE_UNRETURNED,
00071 CLIENT_HANDLE_ALL
00072 };
00073
00074 }
00075
00076 }
00077
00078
00079 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00080 namespace Glib
00081 {
00082
00083 template <>
00084 class Value<Gnome::Conf::ClientErrorHandlingMode> : public Glib::Value_Enum<Gnome::Conf::ClientErrorHandlingMode>
00085 {
00086 public:
00087 static GType value_type() G_GNUC_CONST;
00088 };
00089
00090 }
00091 #endif
00092
00093
00094 namespace Gnome
00095 {
00096
00097 namespace Conf
00098 {
00099
00103 enum ClientPreloadType
00104 {
00105 CLIENT_PRELOAD_NONE,
00106 CLIENT_PRELOAD_ONELEVEL,
00107 CLIENT_PRELOAD_RECURSIVE
00108 };
00109
00110 }
00111
00112 }
00113
00114
00115 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00116 namespace Glib
00117 {
00118
00119 template <>
00120 class Value<Gnome::Conf::ClientPreloadType> : public Glib::Value_Enum<Gnome::Conf::ClientPreloadType>
00121 {
00122 public:
00123 static GType value_type() G_GNUC_CONST;
00124 };
00125
00126 }
00127 #endif
00128
00129
00130 namespace Gnome
00131 {
00132
00133 namespace Conf
00134 {
00135
00136
00139 class Error : public Glib::Error
00140 {
00141 public:
00142 enum Code
00143 {
00144 SUCCESS = 0,
00145 NO_SERVER = 2,
00146 NO_PERMISSION = 3,
00147 BAD_ADDRESS = 4,
00148 PARSE_ERROR = 6,
00149 CORRUPT = 7,
00150 TYPE_MISMATCH = 8,
00151 IS_DIR = 9,
00152 IS_KEY = 10,
00153 OVERRIDDEN = 11,
00154 OAF_ERROR = 12,
00155 LOCAL_ENGINE = 13,
00156 LOCK_FAILED = 14,
00157 NO_WRITABLE_DATABASE = 15,
00158 IN_SHUTDOWN = 16
00159 };
00160
00161 Error(Code error_code, const Glib::ustring& error_message);
00162 explicit Error(GError* gobject);
00163 Code code() const;
00164
00165 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00166 private:
00167
00168 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00169 static void throw_func(GError* gobject);
00170 #else
00171
00172 static std::auto_ptr<Glib::Error> throw_func(GError* gobject);
00173 #endif //GLIBMM_EXCEPTIONS_ENABLED
00174
00175 friend void wrap_init();
00176 #endif
00177 };
00178
00179 }
00180
00181 }
00182
00183 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00184 namespace Glib
00185 {
00186
00187 template <>
00188 class Value<Gnome::Conf::Error::Code> : public Glib::Value_Enum<Gnome::Conf::Error::Code>
00189 {
00190 public:
00191 static GType value_type() G_GNUC_CONST;
00192 };
00193
00194 }
00195 #endif
00196
00197
00198 namespace Gnome
00199 {
00200
00201 namespace Conf
00202 {
00203
00204
00205 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00206 template <typename T>
00207 struct BasicTypeTraits
00208 {
00209 typedef T CppType;
00210 typedef CppType* CType;
00211 typedef CppType* CTypeNonConst;
00212
00213 static CType to_c_type(CppType val)
00214 {
00215 CType pVal = new CppType;
00216 *pVal = val;
00217 return pVal;
00218 }
00219
00220 static CType to_c_type(CType ptr)
00221 { return ptr; }
00222
00223 static CppType to_cpp_type(CType ptr)
00224 {
00225 if(ptr)
00226 {
00227 return *ptr;
00228 }
00229 else
00230 return CppType();
00231 }
00232
00233 static void release_c_type(CType ptr)
00234 {
00235 if(ptr)
00236 delete ptr;
00237 }
00238 };
00239
00240
00241
00242 template <>
00243 struct BasicTypeTraits<int>
00244 {
00245 typedef int CppType;
00246 typedef CppType* CType;
00247 typedef CppType* CTypeNonConst;
00248
00249 static CType to_c_type(CppType val)
00250 { return (int*)GINT_TO_POINTER(val); }
00251
00252 static CType to_c_type(CType ptr)
00253 { return ptr; }
00254
00255 static CppType to_cpp_type(CType ptr)
00256 {
00257 if(ptr)
00258 {
00259 return GPOINTER_TO_INT(ptr);
00260 }
00261 else
00262 return CppType();
00263 }
00264
00265 static void release_c_type(CType )
00266 {
00267 }
00268 };
00269
00270 template <>
00271 struct BasicTypeTraits<bool>
00272 {
00273 typedef bool CppType;
00274 typedef gboolean* CType;
00275 typedef gboolean* CTypeNonConst;
00276
00277 static CType to_c_type(CppType val)
00278 {
00279 return (int*)GINT_TO_POINTER(val);
00280 }
00281
00282 static CType to_c_type(CType ptr)
00283 { return ptr; }
00284
00285 static CppType to_cpp_type(CType ptr)
00286 {
00287 if(ptr)
00288 {
00289
00290 return GPOINTER_TO_INT(ptr);
00291 }
00292 else
00293 return CppType();
00294 }
00295
00296 static void release_c_type(CType )
00297 {
00298
00299 }
00300 };
00301
00302 #endif //DOXYGEN_SHOULD_SKIP_THIS
00303
00304
00315 class Client : public Glib::Object, public SetInterface
00316 {
00317
00318 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00319
00320 public:
00321 typedef Client CppObjectType;
00322 typedef Client_Class CppClassType;
00323 typedef GConfClient BaseObjectType;
00324 typedef GConfClientClass BaseClassType;
00325
00326 private: friend class Client_Class;
00327 static CppClassType client_class_;
00328
00329 private:
00330
00331 Client(const Client&);
00332 Client& operator=(const Client&);
00333
00334 protected:
00335 explicit Client(const Glib::ConstructParams& construct_params);
00336 explicit Client(GConfClient* castitem);
00337
00338 #endif
00339
00340 public:
00341 virtual ~Client();
00342
00343 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00344 static GType get_type() G_GNUC_CONST;
00345 static GType get_base_type() G_GNUC_CONST;
00346 #endif
00347
00349 GConfClient* gobj() { return reinterpret_cast<GConfClient*>(gobject_); }
00350
00352 const GConfClient* gobj() const { return reinterpret_cast<GConfClient*>(gobject_); }
00353
00355 GConfClient* gobj_copy();
00356
00357 private:
00358
00359
00360 public:
00361
00365 static Glib::RefPtr<Client> get_default_client();
00366 static Glib::RefPtr<Client> get_client_for_engine(GConfEngine* engine);
00367
00381 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00382 void add_dir(const Glib::ustring& dir, ClientPreloadType preload = CLIENT_PRELOAD_NONE);
00383 #else
00384 void add_dir(const Glib::ustring& dir, ClientPreloadType preload, std::auto_ptr<Glib::Error>& error);
00385 #endif //GLIBMM_EXCEPTIONS_ENABLED
00386
00387
00391 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00392 void remove_dir(const Glib::ustring& dir);
00393 #else
00394 void remove_dir(const Glib::ustring& dir, std::auto_ptr<Glib::Error>& error);
00395 #endif //GLIBMM_EXCEPTIONS_ENABLED
00396
00397
00398
00417 guint notify_add(const Glib::ustring& namespace_section, Callback callback);
00418
00419
00425 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00426 void notify_remove(guint cnxn);
00427 #else
00428 void notify_remove(guint cnxn, std::auto_ptr<Glib::Error>& error);
00429 #endif //GLIBMM_EXCEPTIONS_ENABLED
00430
00431
00438 void notify(const Glib::ustring& key);
00439
00440
00441 void set_error_handling(ClientErrorHandlingMode mode);
00442
00445 void clear_cache();
00446
00453 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00454 void preload(const Glib::ustring& dirname, ClientPreloadType type);
00455 #else
00456 void preload(const Glib::ustring& dirname, ClientPreloadType type, std::auto_ptr<Glib::Error>& error);
00457 #endif //GLIBMM_EXCEPTIONS_ENABLED
00458
00459
00466 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00467 Value get(const Glib::ustring& key) const;
00468 #else
00469 Value get(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00470 #endif //GLIBMM_EXCEPTIONS_ENABLED
00471
00472
00481 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00482 Value get_without_default(const Glib::ustring& key) const;
00483 #else
00484 Value get_without_default(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00485 #endif //GLIBMM_EXCEPTIONS_ENABLED
00486
00487
00494 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00495 Value get_default_from_schema(const Glib::ustring& key) const;
00496 #else
00497 Value get_default_from_schema(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00498 #endif //GLIBMM_EXCEPTIONS_ENABLED
00499
00500
00509 Entry get_entry(const Glib::ustring& key, bool use_schema_default = true) const;
00510
00520 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00521 Entry get_entry(const Glib::ustring& key, const char* locale, bool use_schema_default = true) const;
00522 #else
00523 Entry get_entry(const Glib::ustring& key, const char* locale, bool use_schema_default, std::auto_ptr<Glib::Error>& error) const;
00524 #endif //GLIBMM_EXCEPTIONS_ENABLED
00525
00526
00532 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00533 void unset(const Glib::ustring& key);
00534 #else
00535 void unset(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error);
00536 #endif //GLIBMM_EXCEPTIONS_ENABLED
00537
00538
00548 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00549 void recursive_unset(const Glib::ustring& key, UnsetFlags flags = UNSET_INCLUDING_SCHEMA_NAMES);
00550 #else
00551 void recursive_unset(const Glib::ustring& key, UnsetFlags flags, std::auto_ptr<Glib::Error>& error);
00552 #endif //GLIBMM_EXCEPTIONS_ENABLED
00553
00554
00562 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00563 Glib::SListHandle<Entry> all_entries(const Glib::ustring& dir) const;
00564 #else
00565 Glib::SListHandle<Entry> all_entries(const Glib::ustring& dir, std::auto_ptr<Glib::Error>& error) const;
00566 #endif //GLIBMM_EXCEPTIONS_ENABLED
00567
00568
00575 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00576 Glib::SListHandle<Glib::ustring> all_dirs(const Glib::ustring& dir) const;
00577 #else
00578 Glib::SListHandle<Glib::ustring> all_dirs(const Glib::ustring& dir, std::auto_ptr<Glib::Error>& error) const;
00579 #endif //GLIBMM_EXCEPTIONS_ENABLED
00580
00581
00587 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00588 void suggest_sync();
00589 #else
00590 void suggest_sync(std::auto_ptr<Glib::Error>& error);
00591 #endif //GLIBMM_EXCEPTIONS_ENABLED
00592
00593
00599 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00600 bool dir_exists(const Glib::ustring&) const;
00601 #else
00602 bool dir_exists(const Glib::ustring& p1, std::auto_ptr<Glib::Error>& error) const;
00603 #endif //GLIBMM_EXCEPTIONS_ENABLED
00604
00605
00611 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00612 bool key_is_writable(const Glib::ustring&) const;
00613 #else
00614 bool key_is_writable(const Glib::ustring& p1, std::auto_ptr<Glib::Error>& error) const;
00615 #endif //GLIBMM_EXCEPTIONS_ENABLED
00616
00617
00625 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00626 double get_float(const Glib::ustring& key) const;
00627 #else
00628 double get_float(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00629 #endif //GLIBMM_EXCEPTIONS_ENABLED
00630
00631
00635 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00636 gint get_int(const Glib::ustring& key) const;
00637 #else
00638 gint get_int(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00639 #endif //GLIBMM_EXCEPTIONS_ENABLED
00640
00641
00645 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00646 bool get_bool(const Glib::ustring& key) const;
00647 #else
00648 bool get_bool(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00649 #endif //GLIBMM_EXCEPTIONS_ENABLED
00650
00651
00655 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00656 Glib::ustring get_string(const Glib::ustring& key) const;
00657 #else
00658 Glib::ustring get_string(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00659 #endif //GLIBMM_EXCEPTIONS_ENABLED
00660
00661
00665 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00666 Schema get_schema(const Glib::ustring& key) const;
00667 #else
00668 Schema get_schema(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00669 #endif //GLIBMM_EXCEPTIONS_ENABLED
00670
00671
00679 SListHandle_ValueInt get_int_list(const Glib::ustring& key) const;
00680
00683 SListHandle_ValueBool get_bool_list(const Glib::ustring& key) const;
00684
00687 SListHandle_ValueFloat get_float_list(const Glib::ustring& key) const;
00688
00691 SListHandle_ValueSchema get_schema_list(const Glib::ustring& key) const;
00692
00695 SListHandle_ValueString get_string_list(const Glib::ustring& key) const;
00696
00697
00706 ValuePair get_pair(const Glib::ustring& key, ValueTypePair types) const;
00707
00708
00715 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00716 void set(const Glib::ustring& key, int what);
00717 #else
00718 void set(const Glib::ustring& key, int what, std::auto_ptr<Glib::Error>& error);
00719 #endif //GLIBMM_EXCEPTIONS_ENABLED
00720
00721
00725 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00726 void set(const Glib::ustring& key, bool what);
00727 #else
00728 void set(const Glib::ustring& key, bool what, std::auto_ptr<Glib::Error>& error);
00729 #endif //GLIBMM_EXCEPTIONS_ENABLED
00730
00731
00735 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00736 void set(const Glib::ustring& key,double what);
00737 #else
00738 void set(const Glib::ustring& key, double what, std::auto_ptr<Glib::Error>& error);
00739 #endif //GLIBMM_EXCEPTIONS_ENABLED
00740
00741
00745 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00746 void set(const Glib::ustring& key, const Glib::ustring& what);
00747 #else
00748 void set(const Glib::ustring& key, const Glib::ustring& what, std::auto_ptr<Glib::Error>& error);
00749 #endif //GLIBMM_EXCEPTIONS_ENABLED
00750
00751
00755 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00756 void set(const Glib::ustring& key, const Schema& what);
00757 #else
00758 void set(const Glib::ustring& key, const Schema& what, std::auto_ptr<Glib::Error>& error);
00759 #endif //GLIBMM_EXCEPTIONS_ENABLED
00760
00761
00766 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00767 void set(const Glib::ustring& key, const Value& what);
00768 #else
00769 void set(const Glib::ustring& key, const Value& what, std::auto_ptr<Glib::Error>& error);
00770 #endif //GLIBMM_EXCEPTIONS_ENABLED
00771
00772
00773 typedef Glib::SListHandle< int, BasicTypeTraits<int> > SListHandleInts;
00774 void set_int_list(const Glib::ustring& key, const SListHandleInts& what);
00775
00776 typedef Glib::SListHandle< bool, BasicTypeTraits<bool> > SListHandleBools;
00777 void set_bool_list(const Glib::ustring& key, const SListHandleBools& what);
00778
00779 typedef Glib::SListHandle< double, BasicTypeTraits<double> > SListHandleFloats;
00780 void set_float_list(const Glib::ustring& key, const SListHandleFloats& what);
00781
00782 void set_schema_list(const Glib::ustring& key, const Glib::SListHandle<Schema>& what);
00783 void set_string_list(const Glib::ustring& key, const Glib::SListHandle<Glib::ustring>& what);
00784
00794 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00795 ChangeSet change_set_from_current(const Glib::SArray& set);
00796 #else
00797 ChangeSet change_set_from_current(const Glib::SArray& set, std::auto_ptr<Glib::Error>& error);
00798 #endif //GLIBMM_EXCEPTIONS_ENABLED
00799
00800
00812 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00813 void change_set_commit(ChangeSet& set, bool remove_commited);
00814 #else
00815 void change_set_commit(ChangeSet& set, bool remove_commited, std::auto_ptr<Glib::Error>& error);
00816 #endif //GLIBMM_EXCEPTIONS_ENABLED
00817
00818
00830 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00831 ChangeSet change_set_reverse(const ChangeSet& set);
00832 #else
00833 ChangeSet change_set_reverse(const ChangeSet& set, std::auto_ptr<Glib::Error>& error);
00834 #endif //GLIBMM_EXCEPTIONS_ENABLED
00835
00836
00844 Glib::SignalProxy2< void,const Glib::ustring&,const Value& > signal_value_changed();
00845
00846
00847 void value_changed(const Glib::ustring& key, const Value& value);
00848
00849 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00850
00851
00852
00858 Glib::SignalProxy1< void,const Glib::Error& > signal_unreturned_error();
00859
00860
00861 void unreturned_error(const Glib::Error& error);
00862 #endif
00863
00871 Glib::SignalProxy1< void,const Glib::Error& > signal_error();
00872
00873
00874 void error(const Glib::Error& error);
00875
00876 private:
00877 void handle_error(GError* pError) const;
00878
00879 GSList* get_list(const Glib::ustring& key, GConfValueType list_type) const;
00880
00881
00882 public:
00883
00884 public:
00885
00886 #ifdef GLIBMM_VFUNCS_ENABLED
00887 #endif //GLIBMM_VFUNCS_ENABLED
00888
00889 protected:
00890
00891 #ifdef GLIBMM_VFUNCS_ENABLED
00892 #endif //GLIBMM_VFUNCS_ENABLED
00893
00894
00895 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00896 virtual void on_value_changed(const Glib::ustring& key, const Value& value);
00897 virtual void on_unreturned_error(const Glib::Error& error);
00898 virtual void on_error(const Glib::Error& error);
00899 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00900
00901
00902 };
00903
00904 }
00905 }
00906
00907
00908 namespace Glib
00909 {
00918 Glib::RefPtr<Gnome::Conf::Client> wrap(GConfClient* object, bool take_copy = false);
00919 }
00920
00921
00922 #endif
00923