Frameworks/libpurple.framework/Versions/0.6.2/Headers/core.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2535 Frameworks/libpurple.framework/Versions/0.6.0/Headers/core.h@39c3c161de14
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
     1 /**
     2  * @file core.h Startup and shutdown of libpurple
     3  * @defgroup core libpurple
     4  * @see @ref core-signals
     5  */
     6 
     7 /* purple
     8  *
     9  * Purple is the legal property of its developers, whose names are too numerous
    10  * to list here.  Please refer to the COPYRIGHT file distributed with this
    11  * source distribution.
    12  *
    13  * This program is free software; you can redistribute it and/or modify
    14  * it under the terms of the GNU General Public License as published by
    15  * the Free Software Foundation; either version 2 of the License, or
    16  * (at your option) any later version.
    17  *
    18  * This program is distributed in the hope that it will be useful,
    19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21  * GNU General Public License for more details.
    22  *
    23  * You should have received a copy of the GNU General Public License
    24  * along with this program; if not, write to the Free Software
    25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
    26  */
    27 #ifndef _PURPLE_CORE_H_
    28 #define _PURPLE_CORE_H_
    29 
    30 typedef struct PurpleCore PurpleCore;
    31 
    32 /** Callbacks that fire at different points of the initialization and teardown
    33  *  of libpurple, along with a hook to return descriptive information about the
    34  *  UI.
    35  */
    36 typedef struct
    37 {
    38 	/** Called just after the preferences subsystem is initialized; the UI
    39 	 *  could use this callback to add some preferences it needs to be in
    40 	 *  place when other subsystems are initialized.
    41 	 */
    42 	void (*ui_prefs_init)(void);
    43 	/** Called just after the debug subsystem is initialized, but before
    44 	 *  just about every other component's initialization.  The UI should
    45 	 *  use this hook to call purple_debug_set_ui_ops() so that debugging
    46 	 *  information for other components can be logged during their
    47 	 *  initialization.
    48 	 */
    49 	void (*debug_ui_init)(void);
    50 	/** Called after all of libpurple has been initialized.  The UI should
    51 	 *  use this hook to set all other necessary UiOps structures.
    52 	 *
    53 	 *  @see @ref ui-ops
    54 	 */
    55 	void (*ui_init)(void);
    56 	/** Called after most of libpurple has been uninitialized. */
    57 	void (*quit)(void);
    58 
    59 	/** Called by purple_core_get_ui_info(); should return the information
    60 	 *  documented there.
    61 	 */
    62 	GHashTable* (*get_ui_info)(void);
    63 
    64 	void (*_purple_reserved1)(void);
    65 	void (*_purple_reserved2)(void);
    66 	void (*_purple_reserved3)(void);
    67 } PurpleCoreUiOps;
    68 
    69 #ifdef __cplusplus
    70 extern "C" {
    71 #endif
    72 
    73 /**
    74  * Initializes the core of purple.
    75  *
    76  * This will setup preferences for all the core subsystems.
    77  *
    78  * @param ui The ID of the UI using the core. This should be a
    79  *           unique ID, registered with the purple team.
    80  *
    81  * @return @c TRUE if successful, or @c FALSE otherwise.
    82  */
    83 gboolean purple_core_init(const char *ui);
    84 
    85 /**
    86  * Quits the core of purple, which, depending on the UI, may quit the
    87  * application using the purple core.
    88  */
    89 void purple_core_quit(void);
    90 
    91 /**
    92  * <p>
    93  * Calls purple_core_quit().  This can be used as the function
    94  * passed to purple_timeout_add() when you want to shutdown Purple
    95  * in a specified amount of time.  When shutting down Purple
    96  * from a plugin, you must use this instead of purple_core_quit();
    97  * for an immediate exit, use a timeout value of 0:
    98  * </p>
    99  *
   100  * <code>purple_timeout_add(0, purple_core_quitcb, NULL);</code>
   101  *
   102  * <p>
   103  * This is ensures that code from your plugin is not being
   104  * executed when purple_core_quit() is called.  If the plugin
   105  * called purple_core_quit() directly, you would get a core dump
   106  * after purple_core_quit() executes and control returns to your
   107  * plugin because purple_core_quit() frees all plugins.
   108  * </p>
   109  */
   110 gboolean purple_core_quit_cb(gpointer unused);
   111 
   112 /**
   113  * Returns the version of the core library.
   114  *
   115  * @return The version of the core library.
   116  */
   117 const char *purple_core_get_version(void);
   118 
   119 /**
   120  * Returns the ID of the UI that is using the core, as passed to
   121  * purple_core_init().
   122  *
   123  * @return The ID of the UI that is currently using the core.
   124  */
   125 const char *purple_core_get_ui(void);
   126 
   127 /**
   128  * Returns a handle to the purple core.
   129  *
   130  * This is used to connect to @ref core-signals "core signals".
   131  */
   132 PurpleCore *purple_get_core(void);
   133 
   134 /**
   135  * Sets the UI ops for the core.
   136  *
   137  * @param ops A UI ops structure for the core.
   138  */
   139 void purple_core_set_ui_ops(PurpleCoreUiOps *ops);
   140 
   141 /**
   142  * Returns the UI ops for the core.
   143  *
   144  * @return The core's UI ops structure.
   145  */
   146 PurpleCoreUiOps *purple_core_get_ui_ops(void);
   147 
   148 /**
   149  * Migrates from <tt>.gaim</tt> to <tt>.purple</tt>.
   150  *
   151  * UIs <strong>must not</strong> call this if they have been told to use a
   152  * custom user directory.
   153  *
   154  * @return A boolean indicating success or migration failure. On failure,
   155  *         the application must display an error to the user and then exit.
   156  */
   157 gboolean purple_core_migrate(void);
   158 
   159 /**
   160  * Ensures that only one instance is running.  If libpurple is built with D-Bus
   161  * support, this checks if another process owns the libpurple bus name and if
   162  * so whether that process is using the same configuration directory as this
   163  * process.
   164  *
   165  * @return @c TRUE if this is the first instance of libpurple running;
   166  *         @c FALSE if there is another instance running.
   167  *
   168  * @since 2.1.0
   169  */
   170 gboolean purple_core_ensure_single_instance(void);
   171 
   172 /**
   173  * Returns a hash table containing various information about the UI.  The
   174  * following well-known entries may be in the table (along with any others the
   175  * UI might choose to include):
   176  *
   177  * <dl>
   178  *   <dt><tt>name</tt></dt>
   179  *   <dd>the user-readable name for the UI.</dd>
   180  *
   181  *   <dt><tt>version</tt></dt>
   182  *   <dd>a user-readable description of the current version of the UI.</dd>
   183  *
   184  *   <dt><tt>website</tt></dt>
   185  *   <dd>the UI's website, such as http://pidgin.im.</dd>
   186  *
   187  *   <dt><tt>dev_website</tt></dt>
   188  *   <dd>the UI's development/support website, such as http://developer.pidgin.im.</dd>
   189  *
   190  *   <dt><tt>client_type</tt></dt>
   191  *   <dd>the type of UI. Possible values include 'pc', 'console', 'phone',
   192  *       'handheld', 'web', and 'bot'. These values are compared
   193  *       programmatically and should not be localized.</dd>
   194  *   
   195  * </dl>
   196  *
   197  * @return A GHashTable with strings for keys and values.  This
   198  * hash table must not be freed and should not be modified.
   199  *
   200  * @since 2.1.0
   201  *
   202  */
   203 GHashTable* purple_core_get_ui_info(void);
   204 
   205 #ifdef __cplusplus
   206 }
   207 #endif
   208 
   209 #endif /* _PURPLE_CORE_H_ */
   210 
   211 /*
   212 
   213                                                   /===-
   214                                                 `//"\\   """"`---.___.-""
   215              ______-==|                         | |  \\           _-"`
   216        __--"""  ,-/-==\\                        | |   `\        ,'
   217     _-"       /'    |  \\            ___         / /      \      /
   218   .'        /       |   \\         /"   "\    /' /        \   /'
   219  /  ____  /         |    \`\.__/-""  D O   \_/'  /          \/'
   220 /-'"    """""---__  |     "-/"   O G     R   /'        _--"`
   221                   \_|      /   R    __--_  t ),   __--""
   222                     '""--_/  T   _-"_>--<_\ h '-" \
   223                    {\__--_/}    / \\__>--<__\ e B  \
   224                    /'   (_/  _-"  | |__>--<__|   U  |
   225                   |   _/) )-"     | |__>--<__|  R   |
   226                   / /" ,_/       / /__>---<__/ N    |
   227                  o-o _//        /-"_>---<__-" I    /
   228                  (^("          /"_>---<__-  N   _-"
   229                 ,/|           /__>--<__/  A  _-"
   230              ,//('(          |__>--<__|  T  /                  .----_
   231             ( ( '))          |__>--<__|    |                 /' _---_"\
   232          `-)) )) (           |__>--<__|  O |               /'  /     "\`\
   233         ,/,'//( (             \__>--<__\  R \            /'  //        ||
   234       ,( ( ((, ))              "-__>--<_"-_  "--____---"' _/'/        /'
   235     `"/  )` ) ,/|                 "-_">--<_/-__       __-" _/
   236   ._-"//( )/ )) `                    ""-'_/_/ /"""""""__--"
   237    ;'( ')/ ,)(                              """"""""""
   238   ' ') '( (/
   239     '   '  `
   240 
   241 */