notify.h

Go to the documentation of this file.
00001 
00006 /* purple
00007  *
00008  * Purple is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  *
00026  * @see @ref notify-signals
00027  */
00028 #ifndef _PURPLE_NOTIFY_H_
00029 #define _PURPLE_NOTIFY_H_
00030 
00031 #include <stdlib.h>
00032 #include <glib-object.h>
00033 #include <glib.h>
00034 
00035 typedef struct _PurpleNotifyUserInfoEntry   PurpleNotifyUserInfoEntry;
00036 typedef struct _PurpleNotifyUserInfo    PurpleNotifyUserInfo;
00037 
00038 #include "connection.h"
00039 
00043 typedef void  (*PurpleNotifyCloseCallback) (gpointer user_data);
00044 
00045 
00049 typedef enum
00050 {
00051     PURPLE_NOTIFY_MESSAGE = 0,   
00052     PURPLE_NOTIFY_EMAIL,         
00053     PURPLE_NOTIFY_EMAILS,        
00054     PURPLE_NOTIFY_FORMATTED,     
00055     PURPLE_NOTIFY_SEARCHRESULTS, 
00056     PURPLE_NOTIFY_USERINFO,      
00057     PURPLE_NOTIFY_URI            
00059 } PurpleNotifyType;
00060 
00061 
00065 typedef enum
00066 {
00067     PURPLE_NOTIFY_MSG_ERROR   = 0, 
00068     PURPLE_NOTIFY_MSG_WARNING,     
00069     PURPLE_NOTIFY_MSG_INFO         
00071 } PurpleNotifyMsgType;
00072 
00073 
00077 typedef enum
00078 {
00079     PURPLE_NOTIFY_BUTTON_LABELED = 0,  
00080     PURPLE_NOTIFY_BUTTON_CONTINUE = 1,
00081     PURPLE_NOTIFY_BUTTON_ADD,
00082     PURPLE_NOTIFY_BUTTON_INFO,
00083     PURPLE_NOTIFY_BUTTON_IM,
00084     PURPLE_NOTIFY_BUTTON_JOIN,
00085     PURPLE_NOTIFY_BUTTON_INVITE
00086 } PurpleNotifySearchButtonType;
00087 
00088 
00092 typedef struct
00093 {
00094     GList *columns;        
00095     GList *rows;           
00096     GList *buttons;        
00098 } PurpleNotifySearchResults;
00099 
00103 typedef enum
00104 {
00105     PURPLE_NOTIFY_USER_INFO_ENTRY_PAIR = 0,
00106     PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK,
00107     PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER
00108 } PurpleNotifyUserInfoEntryType;
00109 
00113 typedef struct
00114 {
00115     char *title; 
00117 } PurpleNotifySearchColumn;
00118 
00119 
00127 typedef void (*PurpleNotifySearchResultsCallback)(PurpleConnection *c, GList *row,
00128                                                 gpointer user_data);
00129 
00130 
00134 typedef struct
00135 {
00136     PurpleNotifySearchButtonType type;
00137     PurpleNotifySearchResultsCallback callback; 
00138     char *label;                              
00139 } PurpleNotifySearchButton;
00140 
00141 
00145 typedef struct
00146 {
00147     void *(*notify_message)(PurpleNotifyMsgType type, const char *title,
00148                             const char *primary, const char *secondary);
00149 
00150     void *(*notify_email)(PurpleConnection *gc,
00151                           const char *subject, const char *from,
00152                           const char *to, const char *url);
00153 
00154     void *(*notify_emails)(PurpleConnection *gc,
00155                            size_t count, gboolean detailed,
00156                            const char **subjects, const char **froms,
00157                            const char **tos, const char **urls);
00158 
00159     void *(*notify_formatted)(const char *title, const char *primary,
00160                               const char *secondary, const char *text);
00161 
00162     void *(*notify_searchresults)(PurpleConnection *gc, const char *title,
00163                                   const char *primary, const char *secondary,
00164                                   PurpleNotifySearchResults *results, gpointer user_data);
00165 
00166     void (*notify_searchresults_new_rows)(PurpleConnection *gc,
00167                                           PurpleNotifySearchResults *results,
00168                                           void *data);
00169 
00170     void *(*notify_userinfo)(PurpleConnection *gc, const char *who,
00171                              PurpleNotifyUserInfo *user_info);
00172 
00173     void *(*notify_uri)(const char *uri);
00174 
00175     void (*close_notify)(PurpleNotifyType type, void *ui_handle);
00176 
00177     void (*_purple_reserved1)(void);
00178     void (*_purple_reserved2)(void);
00179     void (*_purple_reserved3)(void);
00180     void (*_purple_reserved4)(void);
00181 } PurpleNotifyUiOps;
00182 
00183 
00184 #ifdef __cplusplus
00185 extern "C" {
00186 #endif
00187 
00188 
00189 /**************************************************************************/
00191 /**************************************************************************/
00212 void *purple_notify_searchresults(PurpleConnection *gc, const char *title,
00213                                 const char *primary, const char *secondary,
00214                                 PurpleNotifySearchResults *results, PurpleNotifyCloseCallback cb,
00215                                 gpointer user_data);
00216 
00222 void purple_notify_searchresults_free(PurpleNotifySearchResults *results);
00223 
00231 void purple_notify_searchresults_new_rows(PurpleConnection *gc,
00232                                         PurpleNotifySearchResults *results,
00233                                         void *data);
00234 
00235 
00243 void purple_notify_searchresults_button_add(PurpleNotifySearchResults *results,
00244                                           PurpleNotifySearchButtonType type,
00245                                           PurpleNotifySearchResultsCallback cb);
00246 
00247 
00255 void purple_notify_searchresults_button_add_labeled(PurpleNotifySearchResults *results,
00256                                                   const char *label,
00257                                                   PurpleNotifySearchResultsCallback cb);
00258 
00259 
00265 PurpleNotifySearchResults *purple_notify_searchresults_new(void);
00266 
00274 PurpleNotifySearchColumn *purple_notify_searchresults_column_new(const char *title);
00275 
00282 void purple_notify_searchresults_column_add(PurpleNotifySearchResults *results,
00283                                           PurpleNotifySearchColumn *column);
00284 
00291 void purple_notify_searchresults_row_add(PurpleNotifySearchResults *results,
00292                                        GList *row);
00293 
00301 guint purple_notify_searchresults_get_rows_count(PurpleNotifySearchResults *results);
00302 
00310 guint purple_notify_searchresults_get_columns_count(PurpleNotifySearchResults *results);
00311 
00320 GList *purple_notify_searchresults_row_get(PurpleNotifySearchResults *results,
00321                                          unsigned int row_id);
00322 
00331 char *purple_notify_searchresults_column_get_title(PurpleNotifySearchResults *results,
00332                                                  unsigned int column_id);
00333 
00336 /**************************************************************************/
00338 /**************************************************************************/
00355 void *purple_notify_message(void *handle, PurpleNotifyMsgType type,
00356                           const char *title, const char *primary,
00357                           const char *secondary, PurpleNotifyCloseCallback cb,
00358                           gpointer user_data);
00359 
00374 void *purple_notify_email(void *handle, const char *subject,
00375                         const char *from, const char *to,
00376                         const char *url, PurpleNotifyCloseCallback cb,
00377                         gpointer user_data);
00378 
00396 void *purple_notify_emails(void *handle, size_t count, gboolean detailed,
00397                          const char **subjects, const char **froms,
00398                          const char **tos, const char **urls,
00399                          PurpleNotifyCloseCallback cb, gpointer user_data);
00400 
00418 void *purple_notify_formatted(void *handle, const char *title,
00419                             const char *primary, const char *secondary,
00420                             const char *text, PurpleNotifyCloseCallback cb, gpointer user_data);
00421 
00438 void *purple_notify_userinfo(PurpleConnection *gc, const char *who,
00439                            PurpleNotifyUserInfo *user_info, PurpleNotifyCloseCallback cb,
00440                            gpointer user_data);
00441 
00447 PurpleNotifyUserInfo *purple_notify_user_info_new(void);
00448 
00454 void purple_notify_user_info_destroy(PurpleNotifyUserInfo *user_info);
00455 
00469 GList *purple_notify_user_info_get_entries(PurpleNotifyUserInfo *user_info);
00470 
00477 char *purple_notify_user_info_get_text_with_newline(PurpleNotifyUserInfo *user_info, const char *newline);
00478 
00490 void purple_notify_user_info_add_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value);
00491 
00502 void purple_notify_user_info_prepend_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value);
00503 
00510 void purple_notify_user_info_remove_entry(PurpleNotifyUserInfo *user_info, PurpleNotifyUserInfoEntry *user_info_entry);
00526 PurpleNotifyUserInfoEntry *purple_notify_user_info_entry_new(const char *label, const char *value);
00527 
00533 void purple_notify_user_info_add_section_break(PurpleNotifyUserInfo *user_info);
00534 
00541 void purple_notify_user_info_add_section_header(PurpleNotifyUserInfo *user_info, const char *label);
00542 
00546 void purple_notify_user_info_remove_last_item(PurpleNotifyUserInfo *user_info);
00547 
00555 gchar *purple_notify_user_info_entry_get_label(PurpleNotifyUserInfoEntry *user_info_entry);
00556 
00563 void purple_notify_user_info_entry_set_label(PurpleNotifyUserInfoEntry *user_info_entry, const char *label);
00564 
00572 gchar *purple_notify_user_info_entry_get_value(PurpleNotifyUserInfoEntry *user_info_entry);
00573 
00580 void purple_notify_user_info_entry_set_value(PurpleNotifyUserInfoEntry *user_info_entry, const char *value);
00581 
00582 
00590 PurpleNotifyUserInfoEntryType purple_notify_user_info_entry_get_type(PurpleNotifyUserInfoEntry *user_info_entry);
00591 
00598 void purple_notify_user_info_entry_set_type(PurpleNotifyUserInfoEntry *user_info_entry,
00599                                           PurpleNotifyUserInfoEntryType type);
00600 
00611 void *purple_notify_uri(void *handle, const char *uri);
00612 
00622 void purple_notify_close(PurpleNotifyType type, void *ui_handle);
00623 
00629 void purple_notify_close_with_handle(void *handle);
00630 
00634 #define purple_notify_info(handle, title, primary, secondary) \
00635     purple_notify_message((handle), PURPLE_NOTIFY_MSG_INFO, (title), \
00636                         (primary), (secondary), NULL, NULL)
00637 
00641 #define purple_notify_warning(handle, title, primary, secondary) \
00642     purple_notify_message((handle), PURPLE_NOTIFY_MSG_WARNING, (title), \
00643                         (primary), (secondary), NULL, NULL)
00644 
00648 #define purple_notify_error(handle, title, primary, secondary) \
00649     purple_notify_message((handle), PURPLE_NOTIFY_MSG_ERROR, (title), \
00650                         (primary), (secondary), NULL, NULL)
00651 
00654 /**************************************************************************/
00656 /**************************************************************************/
00665 void purple_notify_set_ui_ops(PurpleNotifyUiOps *ops);
00666 
00673 PurpleNotifyUiOps *purple_notify_get_ui_ops(void);
00674 
00677 /**************************************************************************/
00679 /**************************************************************************/
00687 void *purple_notify_get_handle(void);
00688 
00692 void purple_notify_init(void);
00693 
00697 void purple_notify_uninit(void);
00698 
00702 #ifdef __cplusplus
00703 }
00704 #endif
00705 
00706 #endif /* _PURPLE_NOTIFY_H_ */