comparison src/blist.h @ 9787:904b757835ca

[gaim-migrate @ 10655] after an utter failure to get comments on this since it was updated, and thinking that the functionality is worth having, i present to you: " This is a patch to blist.c and blist.h to modify the GaimBuddy structure to add a field for flags. It also adds a single flag GAIM_BUDDY_NO_SAVE, which can be used to indicate that a particular buddy should not be saved to file. This will be particularly useful for prpls with dynamic group support (which I am working on adding to Meanwhile), such as Oscar's recent buddies group. I used a negative flag (NO_SAVE rather than SAVE) because the default should be for saving to happen, and I didn't want to have to initiate the buddy with a save flag set. To counteract this, there is a macro called GAIM_BUDDY_SHOULD_SAVE which checks for the absense of the flag. Woo-hoo double negative!! The beefy part of this patch also factors out the deeply nested loops of the saving code into separate functions. This code also fixes a minor possible bug wherein when saving only a particular account, a group could be written containing empty contacts (due to checking for the specific account only at the group and buddy levels) Here's a version that places the flags field in the BlistNode, and checks for it at each stage (group, chat, contact, buddy). It didn't erase my buddy list when I tried it, so that's nice at least." --Christopher (siege) O'Brien committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Fri, 20 Aug 2004 03:40:33 +0000
parents 4a8bf81b82ae
children fb08a0973b3e
comparison
equal deleted inserted replaced
9786:3e7e294f56f3 9787:904b757835ca
72 72
73 #define GAIM_BUDDY_IS_ONLINE(b) ((b)->account->gc && \ 73 #define GAIM_BUDDY_IS_ONLINE(b) ((b)->account->gc && \
74 ((b)->present == GAIM_BUDDY_ONLINE || \ 74 ((b)->present == GAIM_BUDDY_ONLINE || \
75 (b)->present == GAIM_BUDDY_SIGNING_ON)) 75 (b)->present == GAIM_BUDDY_SIGNING_ON))
76 76
77 typedef enum
78 {
79 GAIM_BLIST_NODE_FLAG_NO_SAVE = 1, /**< node should not be saved with the buddy list */
80 } GaimBlistNodeFlags;
81
82 #define GAIM_BLIST_NODE_HAS_FLAG(b, f) ((b)->flags & (f))
83 #define GAIM_BLIST_NODE_SHOULD_SAVE(b) (! GAIM_BLIST_NODE_HAS_FLAG(b, GAIM_BLIST_NODE_FLAG_NO_SAVE))
84
77 85
78 /**************************************************************************/ 86 /**************************************************************************/
79 /* Data Structures */ 87 /* Data Structures */
80 /**************************************************************************/ 88 /**************************************************************************/
81 89
88 GaimBlistNode *next; /**< The sibling after this buddy. */ 96 GaimBlistNode *next; /**< The sibling after this buddy. */
89 GaimBlistNode *parent; /**< The parent of this node */ 97 GaimBlistNode *parent; /**< The parent of this node */
90 GaimBlistNode *child; /**< The child of this node */ 98 GaimBlistNode *child; /**< The child of this node */
91 GHashTable *settings; /**< per-node settings */ 99 GHashTable *settings; /**< per-node settings */
92 void *ui_data; /**< The UI can put data here. */ 100 void *ui_data; /**< The UI can put data here. */
101 GaimBlistNodeFlags flags; /**< The buddy flags */
93 }; 102 };
94 103
95 /** 104 /**
96 * A buddy. This contains everything Gaim will ever need to know about someone on the buddy list. Everything. 105 * A buddy. This contains everything Gaim will ever need to know about someone on the buddy list. Everything.
97 */ 106 */
106 time_t signon; /**< The time the buddy signed on. */ 115 time_t signon; /**< The time the buddy signed on. */
107 int idle; /**< The time the buddy has been idle in minutes. */ 116 int idle; /**< The time the buddy has been idle in minutes. */
108 int uc; /**< This is a cryptic bitmask that makes sense only to the prpl. This will get changed */ 117 int uc; /**< This is a cryptic bitmask that makes sense only to the prpl. This will get changed */
109 void *proto_data; /**< This allows the prpl to associate whatever data it wants with a buddy */ 118 void *proto_data; /**< This allows the prpl to associate whatever data it wants with a buddy */
110 GaimBuddyIcon *icon; /**< The buddy icon. */ 119 GaimBuddyIcon *icon; /**< The buddy icon. */
111 GaimAccount *account; /**< the account this buddy belongs to */ 120 GaimAccount *account; /**< the account this buddy belongs to */
112 guint timer; /**< The timer handle. */ 121 guint timer; /**< The timer handle. */
113 }; 122 };
114 123
115 /** 124 /**
116 * A contact. This contains everything Gaim will ever need to know about a contact. 125 * A contact. This contains everything Gaim will ever need to know about a contact.
117 */ 126 */
491 * @return The alias, or NULL if it is not set. 500 * @return The alias, or NULL if it is not set.
492 */ 501 */
493 const char *gaim_contact_get_alias(GaimContact *contact); 502 const char *gaim_contact_get_alias(GaimContact *contact);
494 503
495 /** 504 /**
505 * Determines whether an account owns any buddies in a given contact
506 *
507 * @param contact The contact to search through.
508 * @param account The account.
509 *
510 * @return TRUE if there are any buddies from account in the contact, or FALSE otherwise.
511 */
512 gboolean gaim_contact_on_account(GaimContact *contact, GaimAccount *account);
513
514
515 /**
496 * Removes a buddy from the buddy list and frees the memory allocated to it. 516 * Removes a buddy from the buddy list and frees the memory allocated to it.
497 * 517 *
498 * @param buddy The buddy to be removed 518 * @param buddy The buddy to be removed
499 */ 519 */
500 void gaim_blist_remove_buddy(GaimBuddy *buddy); 520 void gaim_blist_remove_buddy(GaimBuddy *buddy);