client.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Generated by gtkmmproc -- DO NOT MODIFY!
00003 #ifndef _GCONFMM_CLIENT_H
00004 #define _GCONFMM_CLIENT_H
00005 
00006 
00007 #include <glibmm.h>
00008 
00009 // -*- Mode: C++; c-basic-offset: 4 -*-
00010 /* $Id: client.hg,v 1.25 2005/03/03 13:17:47 murrayc Exp $ */
00011 
00012 /* client.hg
00013  * 
00014  * Copyright (C) 2000-2002 GConfmm Development Team
00015  *
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Library General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2 of the License, or (at your option) any later version.
00020  *
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Library General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU Library General Public
00027  * License along with this library; if not, write to the Free
00028  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 /* DOXYGEN_SHOULD_SKIP_THIS */
00048 
00049 
00050 namespace Gnome
00051 {
00052 
00053 namespace Conf
00054 { class Client_Class; } // namespace Conf
00055 
00056 } // namespace Gnome
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 } // namespace Conf
00075 
00076 } // namespace Gnome
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 } // namespace Glib
00091 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
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 } // namespace Conf
00111 
00112 } // namespace Gnome
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 } // namespace Glib
00127 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
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   //When not using exceptions, we just pass the Exception object around without throwing it:
00172   static std::auto_ptr<Glib::Error> throw_func(GError* gobject);
00173 #endif //GLIBMM_EXCEPTIONS_ENABLED
00174 
00175   friend void wrap_init(); // uses throw_func()
00176 #endif
00177 };
00178 
00179 } // namespace Conf
00180 
00181 } // namespace Gnome
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 } // namespace Glib
00195 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
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 //Template specialization:
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 /* ptr */)
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       //We use this for gboolean too, because it is actually an int.
00290       return GPOINTER_TO_INT(ptr);
00291     }
00292     else
00293       return CppType();
00294   }
00295   
00296   static void release_c_type(CType /* ptr */)
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   // noncopyable
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 /* DOXYGEN_SHOULD_SKIP_THIS */
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     // API-TODO: Should this return a Connection ?
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     
00432   void set_error_handling(ClientErrorHandlingMode mode);
00433     
00436   void clear_cache();
00437     
00444 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00445   void preload(const Glib::ustring& dirname, ClientPreloadType type);
00446 #else
00447   void preload(const Glib::ustring& dirname, ClientPreloadType type, std::auto_ptr<Glib::Error>& error);
00448 #endif //GLIBMM_EXCEPTIONS_ENABLED
00449 
00450     
00457 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00458   Value get(const Glib::ustring& key) const;
00459 #else
00460   Value get(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00461 #endif //GLIBMM_EXCEPTIONS_ENABLED
00462 
00463 
00472 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00473   Value get_without_default(const Glib::ustring& key) const;
00474 #else
00475   Value get_without_default(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00476 #endif //GLIBMM_EXCEPTIONS_ENABLED
00477 
00478 
00485 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00486   Value get_default_from_schema(const Glib::ustring& key) const;
00487 #else
00488   Value get_default_from_schema(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00489 #endif //GLIBMM_EXCEPTIONS_ENABLED
00490 
00491 
00500     Entry get_entry(const Glib::ustring& key, bool use_schema_default = true) const;
00501       
00511 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00512   Entry get_entry(const Glib::ustring& key, const char* locale, bool use_schema_default = true) const;
00513 #else
00514   Entry get_entry(const Glib::ustring& key, const char* locale, bool use_schema_default, std::auto_ptr<Glib::Error>& error) const;
00515 #endif //GLIBMM_EXCEPTIONS_ENABLED
00516 
00517     
00523 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00524   void unset(const Glib::ustring& key);
00525 #else
00526   void unset(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error);
00527 #endif //GLIBMM_EXCEPTIONS_ENABLED
00528 
00529     
00537 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00538   Glib::SListHandle<Entry> all_entries(const Glib::ustring& dir) const;
00539 #else
00540   Glib::SListHandle<Entry> all_entries(const Glib::ustring& dir, std::auto_ptr<Glib::Error>& error) const;
00541 #endif //GLIBMM_EXCEPTIONS_ENABLED
00542 
00543 
00550 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00551   Glib::SListHandle<Glib::ustring> all_dirs(const Glib::ustring& dir) const;
00552 #else
00553   Glib::SListHandle<Glib::ustring> all_dirs(const Glib::ustring& dir, std::auto_ptr<Glib::Error>& error) const;
00554 #endif //GLIBMM_EXCEPTIONS_ENABLED
00555 
00556     
00562 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00563   void suggest_sync();
00564 #else
00565   void suggest_sync(std::auto_ptr<Glib::Error>& error);
00566 #endif //GLIBMM_EXCEPTIONS_ENABLED
00567 
00568 
00574 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00575   bool dir_exists(const Glib::ustring&) const;
00576 #else
00577   bool dir_exists(const Glib::ustring& p1, std::auto_ptr<Glib::Error>& error) const;
00578 #endif //GLIBMM_EXCEPTIONS_ENABLED
00579 
00580 
00586 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00587   bool key_is_writable(const Glib::ustring&) const;
00588 #else
00589   bool key_is_writable(const Glib::ustring& p1, std::auto_ptr<Glib::Error>& error) const;
00590 #endif //GLIBMM_EXCEPTIONS_ENABLED
00591 
00592     
00600 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00601   double get_float(const Glib::ustring& key) const;
00602 #else
00603   double get_float(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00604 #endif //GLIBMM_EXCEPTIONS_ENABLED
00605 
00606 
00610 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00611   gint get_int(const Glib::ustring& key) const;
00612 #else
00613   gint get_int(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00614 #endif //GLIBMM_EXCEPTIONS_ENABLED
00615 
00616 
00620 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00621   bool get_bool(const Glib::ustring& key) const;
00622 #else
00623   bool get_bool(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00624 #endif //GLIBMM_EXCEPTIONS_ENABLED
00625 
00626 
00630 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00631   Glib::ustring get_string(const Glib::ustring& key) const;
00632 #else
00633   Glib::ustring get_string(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00634 #endif //GLIBMM_EXCEPTIONS_ENABLED
00635 
00636 
00640 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00641   Schema get_schema(const Glib::ustring& key) const;
00642 #else
00643   Schema get_schema(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
00644 #endif //GLIBMM_EXCEPTIONS_ENABLED
00645 
00646 
00654     SListHandle_ValueInt    get_int_list(const Glib::ustring& key) const;
00655 
00658     SListHandle_ValueBool   get_bool_list(const Glib::ustring& key) const;
00659 
00662     SListHandle_ValueFloat  get_float_list(const Glib::ustring& key) const;
00663 
00666     SListHandle_ValueSchema get_schema_list(const Glib::ustring& key) const;
00667 
00670     SListHandle_ValueString get_string_list(const Glib::ustring& key) const;
00671     
00672     
00681     ValuePair get_pair(const Glib::ustring& key, ValueTypePair types) const;
00682     
00683     
00690 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00691   void set(const Glib::ustring& key, int what);
00692 #else
00693   void set(const Glib::ustring& key, int what, std::auto_ptr<Glib::Error>& error);
00694 #endif //GLIBMM_EXCEPTIONS_ENABLED
00695 
00696 
00700 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00701   void set(const Glib::ustring& key, bool what);
00702 #else
00703   void set(const Glib::ustring& key, bool what, std::auto_ptr<Glib::Error>& error);
00704 #endif //GLIBMM_EXCEPTIONS_ENABLED
00705 
00706 
00710 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00711   void set(const Glib::ustring& key,double what);
00712 #else
00713   void set(const Glib::ustring& key, double what, std::auto_ptr<Glib::Error>& error);
00714 #endif //GLIBMM_EXCEPTIONS_ENABLED
00715 
00716 
00720 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00721   void set(const Glib::ustring& key, const Glib::ustring& what);
00722 #else
00723   void set(const Glib::ustring& key, const Glib::ustring& what, std::auto_ptr<Glib::Error>& error);
00724 #endif //GLIBMM_EXCEPTIONS_ENABLED
00725 
00726 
00730 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00731   void set(const Glib::ustring& key, const Schema& what);
00732 #else
00733   void set(const Glib::ustring& key, const Schema& what, std::auto_ptr<Glib::Error>& error);
00734 #endif //GLIBMM_EXCEPTIONS_ENABLED
00735 
00736 
00741 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00742   void set(const Glib::ustring& key, const Value& what);
00743 #else
00744   void set(const Glib::ustring& key, const Value& what, std::auto_ptr<Glib::Error>& error);
00745 #endif //GLIBMM_EXCEPTIONS_ENABLED
00746 
00747     
00748     typedef Glib::SListHandle< int, BasicTypeTraits<int> > SListHandleInts;
00749     void set_int_list(const Glib::ustring& key, const SListHandleInts& what);
00750     
00751     typedef Glib::SListHandle< bool, BasicTypeTraits<bool> > SListHandleBools;
00752     void set_bool_list(const Glib::ustring& key, const SListHandleBools& what);
00753     
00754     typedef Glib::SListHandle< double, BasicTypeTraits<double> > SListHandleFloats;
00755     void set_float_list(const Glib::ustring& key, const SListHandleFloats& what);
00756     
00757     void set_schema_list(const Glib::ustring& key, const Glib::SListHandle<Schema>& what);
00758     void set_string_list(const Glib::ustring& key, const Glib::SListHandle<Glib::ustring>& what);
00759     
00769 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00770   ChangeSet change_set_from_current(const Glib::SArray& set);
00771 #else
00772   ChangeSet change_set_from_current(const Glib::SArray& set, std::auto_ptr<Glib::Error>& error);
00773 #endif //GLIBMM_EXCEPTIONS_ENABLED
00774 
00775     
00787 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00788   void change_set_commit(ChangeSet& set, bool remove_commited);
00789 #else
00790   void change_set_commit(ChangeSet& set, bool remove_commited, std::auto_ptr<Glib::Error>& error);
00791 #endif //GLIBMM_EXCEPTIONS_ENABLED
00792 
00793 
00805 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00806   ChangeSet change_set_reverse(const ChangeSet& set);
00807 #else
00808   ChangeSet change_set_reverse(const ChangeSet& set, std::auto_ptr<Glib::Error>& error);
00809 #endif //GLIBMM_EXCEPTIONS_ENABLED
00810 
00811 
00817   Glib::SignalProxy2< void,const Glib::ustring&,const Value& > signal_value_changed();
00818 
00819     
00820   void value_changed(const Glib::ustring& key, const Value& value);
00821 
00822 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00823     // unreturned_error will never be called, as gconfmm
00824     // catches all GError's and throw()s them as Gnome::Conf::Error's.
00825     
00826 
00827   Glib::SignalProxy1< void,const Glib::Error& > signal_unreturned_error();
00828 
00829     
00830   void unreturned_error(const Glib::Error& error);
00831 #endif
00832 
00838   Glib::SignalProxy1< void,const Glib::Error& > signal_error();
00839 
00840     
00841   void error(const Glib::Error& error);
00842     
00843 private:
00844     void handle_error(GError* pError) const;
00845     
00846     GSList* get_list(const Glib::ustring& key, GConfValueType list_type) const;
00847 
00848 
00849 public:
00850 
00851 public:
00852   //C++ methods used to invoke GTK+ virtual functions:
00853 #ifdef GLIBMM_VFUNCS_ENABLED
00854 #endif //GLIBMM_VFUNCS_ENABLED
00855 
00856 protected:
00857   //GTK+ Virtual Functions (override these to change behaviour):
00858 #ifdef GLIBMM_VFUNCS_ENABLED
00859 #endif //GLIBMM_VFUNCS_ENABLED
00860 
00861   //Default Signal Handlers::
00862   virtual void on_value_changed(const Glib::ustring& key, const Value& value);
00863   virtual void on_unreturned_error(const Glib::Error& error);
00864   virtual void on_error(const Glib::Error& error);
00865 
00866 
00867 };
00868 
00869 } /* namespace Conf */
00870 } /* namespace Gnome */
00871 
00872 
00873 namespace Glib
00874 {
00880   Glib::RefPtr<Gnome::Conf::Client> wrap(GConfClient* object, bool take_copy = false);
00881 }
00882 
00883 
00884 #endif /* _GCONFMM_CLIENT_H */
00885 

Generated on Fri Aug 11 09:35:40 2006 for gconfmm by  doxygen 1.4.7