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