Frameworks/libpurple.framework/Versions/0.6.2/Headers/user.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2250 Frameworks/libpurple.framework/Versions/0.6.0/Headers/user.h@9da0b118ce57
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
     1 /**
     2  * @file user.h User functions
     3  *
     4  * purple
     5  *
     6  * Purple is the legal property of its developers, whose names are too numerous
     7  * to list here.  Please refer to the COPYRIGHT file distributed with this
     8  * source distribution.
     9  *
    10  * This program is free software; you can redistribute it and/or modify
    11  * it under the terms of the GNU General Public License as published by
    12  * the Free Software Foundation; either version 2 of the License, or
    13  * (at your option) any later version.
    14  *
    15  * This program is distributed in the hope that it will be useful,
    16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  * GNU General Public License for more details.
    19  *
    20  * You should have received a copy of the GNU General Public License
    21  * along with this program; if not, write to the Free Software
    22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
    23  */
    24 #ifndef _MSN_USER_H_
    25 #define _MSN_USER_H_
    26 
    27 typedef struct _MsnUser  MsnUser;
    28 
    29 #include "session.h"
    30 #include "object.h"
    31 
    32 #include "userlist.h"
    33 
    34 typedef enum
    35 {
    36 	MSN_NETWORK_UNKNOWN      = 0x00,
    37 	MSN_NETWORK_PASSPORT     = 0x01,
    38 	MSN_NETWORK_COMMUNICATOR = 0x02,
    39 	MSN_NETWORK_MOBILE       = 0x04,
    40 	MSN_NETWORK_MNI          = 0x08,
    41 	MSN_NETWORK_SMTP         = 0x10,
    42 	MSN_NETWORK_YAHOO        = 0x20
    43 } MsnNetwork;
    44 
    45 /**
    46  * Current media.
    47  */
    48 typedef enum
    49 {
    50 	CURRENT_MEDIA_UNKNOWN,
    51 	CURRENT_MEDIA_MUSIC,
    52 	CURRENT_MEDIA_GAMES,
    53 	CURRENT_MEDIA_OFFICE
    54 } CurrentMediaType;
    55 
    56 typedef struct _CurrentMedia
    57 {
    58 	CurrentMediaType type;     /**< Type.   */
    59 	char *title;    /**< Title.  */
    60 	char *artist;   /**< Artist. */
    61 	char *album;    /**< Album.  */
    62 } CurrentMedia;
    63 
    64 /**
    65  * A user.
    66  */
    67 struct _MsnUser
    68 {
    69 	MsnUserList *userlist;
    70 
    71 	char *passport;         /**< The passport account.          */
    72 	char *friendly_name;    /**< The friendly name.             */
    73 
    74 	char * uid;				/*< User Id							*/
    75 
    76 	const char *status;     /**< The state of the user.         */
    77 	char *statusline;       /**< The state of the user.         */
    78 	CurrentMedia media;     /**< Current media of the user.     */
    79 
    80 	gboolean idle;          /**< The idle state of the user.    */
    81 
    82 	struct
    83 	{
    84 		char *home;         /**< Home phone number.             */
    85 		char *work;         /**< Work phone number.             */
    86 		char *mobile;       /**< Mobile phone number.           */
    87 
    88 	} phone;
    89 
    90 	gboolean authorized;    /**< Authorized to add this user.   */
    91 	gboolean mobile;        /**< Signed up with MSN Mobile.     */
    92 
    93 	GList *group_ids;       /**< The group IDs.                 */
    94 	char *pending_group;    /**< A pending group to add.        */
    95 
    96 	MsnObject *msnobj;      /**< The user's MSN Object.         */
    97 
    98 	GHashTable *clientcaps; /**< The client's capabilities.     */
    99 
   100 	guint clientid;         /**< The client's ID                */
   101 
   102 	MsnNetwork networkid;   /**< The user's network             */
   103 
   104 	int list_op;            /**< Which lists the user is in     */
   105 
   106 	guint membership_id[5];	/**< The membershipId sent by the contacts server,
   107 				     indexed by the list it belongs to		*/
   108 
   109 	char *invite_message;   /**< Invite message of user request */
   110 };
   111 
   112 /**************************************************************************
   113  ** @name User API                                                        *
   114  **************************************************************************/
   115 /*@{*/
   116 
   117 /**
   118  * Creates a new user structure.
   119  *
   120  * @param session      The MSN session.
   121  * @param passport     The initial passport.
   122  * @param stored_name  The initial stored name.
   123  *
   124  * @return A new user structure.
   125  */
   126 MsnUser *msn_user_new(MsnUserList *userlist, const char *passport,
   127 					  const char *friendly_name);
   128 
   129 /**
   130  * Destroys a user structure.
   131  *
   132  * @param user The user to destroy.
   133  */
   134 void msn_user_destroy(MsnUser *user);
   135 
   136 
   137 /**
   138  * Updates the user.
   139  *
   140  * Communicates with the core to update the ui, etc.
   141  *
   142  * @param user The user to update.
   143  */
   144 void msn_user_update(MsnUser *user);
   145 
   146  /**
   147   *  Sets the new statusline of user.
   148   *
   149   *  @param user The user.
   150   *  @param state The statusline string.
   151   */
   152 void msn_user_set_statusline(MsnUser *user, const char *statusline);
   153 
   154  /**
   155   *  Sets the current media of user.
   156   *
   157   *  @param user   The user.
   158   *  @param cmedia Current media.
   159   */
   160 void msn_user_set_currentmedia(MsnUser *user, const CurrentMedia *cmedia);
   161 
   162 /**
   163  * Sets the new state of user.
   164  *
   165  * @param user The user.
   166  * @param state The state string.
   167  */
   168 void msn_user_set_state(MsnUser *user, const char *state);
   169 
   170 /**
   171  * Sets the passport account for a user.
   172  *
   173  * @param user     The user.
   174  * @param passport The passport account.
   175  */
   176 void msn_user_set_passport(MsnUser *user, const char *passport);
   177 
   178 /**
   179  * Sets the friendly name for a user.
   180  *
   181  * @param user The user.
   182  * @param name The friendly name.
   183  *
   184  * @returns TRUE is name actually changed, FALSE otherwise.
   185  */
   186 gboolean msn_user_set_friendly_name(MsnUser *user, const char *name);
   187 
   188 /**
   189  * Sets the buddy icon for a local user.
   190  *
   191  * @param user     The user.
   192  * @param img      The buddy icon image
   193  */
   194 void msn_user_set_buddy_icon(MsnUser *user, PurpleStoredImage *img);
   195 
   196 /**
   197  * Sets the group ID list for a user.
   198  *
   199  * @param user The user.
   200  * @param ids  The group ID list.
   201  */
   202 void msn_user_set_group_ids(MsnUser *user, GList *ids);
   203 
   204 /**
   205  * Adds the group ID for a user.
   206  *
   207  * @param user The user.
   208  * @param id   The group ID.
   209  */
   210 void msn_user_add_group_id(MsnUser *user, const char * id);
   211 
   212 /**
   213  * Removes the group ID from a user.
   214  *
   215  * @param user The user.
   216  * @param id   The group ID.
   217  */
   218 void msn_user_remove_group_id(MsnUser *user, const char * id);
   219 
   220 /**
   221  * Sets the pending group for a user.
   222  *
   223  * @param user  The user.
   224  * @param group The group name.
   225  */
   226 void msn_user_set_pending_group(MsnUser *user, const char *group);
   227 
   228 /**
   229  * Removes the pending group from a user.
   230  *
   231  * @param user The user.
   232  *
   233  * @return Returns the pending group name.
   234  */
   235 char *msn_user_remove_pending_group(MsnUser *user);
   236 
   237 /**
   238  * Sets the home phone number for a user.
   239  *
   240  * @param user   The user.
   241  * @param number The home phone number.
   242  */
   243 void msn_user_set_home_phone(MsnUser *user, const char *number);
   244 
   245 /**
   246  * Sets the work phone number for a user.
   247  *
   248  * @param user   The user.
   249  * @param number The work phone number.
   250  */
   251 void msn_user_set_work_phone(MsnUser *user, const char *number);
   252 
   253 void msn_user_set_uid(MsnUser *user, const char *uid);
   254 
   255 /**
   256  * Sets the client id for a user.
   257  *
   258  * @param user     The user.
   259  * @param clientid The client id.
   260  */
   261 void msn_user_set_clientid(MsnUser *user, guint clientid);
   262 
   263 /**
   264  * Sets the network id for a user.
   265  *
   266  * @param user    The user.
   267  * @param network The network id.
   268  */
   269 void msn_user_set_network(MsnUser *user, MsnNetwork network);
   270 
   271 /**
   272  * Sets the mobile phone number for a user.
   273  *
   274  * @param user   The user.
   275  * @param number The mobile phone number.
   276  */
   277 void msn_user_set_mobile_phone(MsnUser *user, const char *number);
   278 
   279 /**
   280  * Sets the MSNObject for a user.
   281  *
   282  * @param user The user.
   283  * @param obj  The MSNObject.
   284  */
   285 void msn_user_set_object(MsnUser *user, MsnObject *obj);
   286 
   287 /**
   288  * Sets the client information for a user.
   289  *
   290  * @param user The user.
   291  * @param info The client information.
   292  */
   293 void msn_user_set_client_caps(MsnUser *user, GHashTable *info);
   294 
   295 /**
   296  * Sets the invite message for a user.
   297  *
   298  * @param user    The user.
   299  * @param message The invite message for a user.
   300  */
   301 void msn_user_set_invite_message(MsnUser *user, const char *message);
   302 
   303 
   304 /**
   305  * Returns the passport account for a user.
   306  *
   307  * @param user The user.
   308  *
   309  * @return The passport account.
   310  */
   311 const char *msn_user_get_passport(const MsnUser *user);
   312 
   313 /**
   314  * Returns the friendly name for a user.
   315  *
   316  * @param user The user.
   317  *
   318  * @return The friendly name.
   319  */
   320 const char *msn_user_get_friendly_name(const MsnUser *user);
   321 
   322 /**
   323  * Returns the home phone number for a user.
   324  *
   325  * @param user The user.
   326  *
   327  * @return The user's home phone number.
   328  */
   329 const char *msn_user_get_home_phone(const MsnUser *user);
   330 
   331 /**
   332  * Returns the work phone number for a user.
   333  *
   334  * @param user The user.
   335  *
   336  * @return The user's work phone number.
   337  */
   338 const char *msn_user_get_work_phone(const MsnUser *user);
   339 
   340 /**
   341  * Returns the mobile phone number for a user.
   342  *
   343  * @param user The user.
   344  *
   345  * @return The user's mobile phone number.
   346  */
   347 const char *msn_user_get_mobile_phone(const MsnUser *user);
   348 
   349 /**
   350  * Returns the client id for a user.
   351  *
   352  * @param user    The user.
   353  *
   354  * @return The user's client id.
   355  */
   356 guint msn_user_get_clientid(const MsnUser *user);
   357 
   358 /**
   359  * Returns the network id for a user.
   360  *
   361  * @param user    The user.
   362  *
   363  * @return The user's network id.
   364  */
   365 MsnNetwork msn_user_get_network(const MsnUser *user);
   366 
   367 /**
   368  * Returns the MSNObject for a user.
   369  *
   370  * @param user The user.
   371  *
   372  * @return The MSNObject.
   373  */
   374 MsnObject *msn_user_get_object(const MsnUser *user);
   375 
   376 /**
   377  * Returns the client information for a user.
   378  *
   379  * @param user The user.
   380  *
   381  * @return The client information.
   382  */
   383 GHashTable *msn_user_get_client_caps(const MsnUser *user);
   384 
   385 /**
   386  * Returns the invite message for a user.
   387  *
   388  * @param user The user.
   389  *
   390  * @return The user's invite message.
   391  */
   392 const char *msn_user_get_invite_message(const MsnUser *user);
   393 
   394 /**
   395  * check to see if user is online
   396  */
   397 gboolean
   398 msn_user_is_online(PurpleAccount *account, const char *name);
   399 
   400 /**
   401  * check to see if user is Yahoo User
   402  */
   403 gboolean
   404 msn_user_is_yahoo(PurpleAccount *account ,const char *name);
   405 
   406 void msn_user_set_op(MsnUser *user, int list_op);
   407 void msn_user_unset_op(MsnUser *user, int list_op);
   408 
   409 /*@}*/
   410 
   411 
   412 #endif /* _MSN_USER_H_ */