void BuddyListGroup::initCollapsedState() { /* This can't be done when the purple_blist_load() function was called * because node settings are unavailable at that time. */ treeview->setCollapsed(ref, purple_blist_node_get_bool(blist_node, "collapsed")); }
void otrg_prefs_buddy_load(PurpleBuddy *buddy, gboolean *usedefaultp, gboolean *enabledp, gboolean *automaticp, gboolean *onlyprivatep, gboolean *avoidloggingotrp) { PurpleBlistNode *node = &(buddy->node); *usedefaultp = !purple_blist_node_get_bool(node, "OTR/overridedefault"); if (*usedefaultp) { otrg_prefs_global_load(enabledp, automaticp, onlyprivatep, avoidloggingotrp); } else { *enabledp = purple_blist_node_get_bool(node, "OTR/enabled"); *automaticp = purple_blist_node_get_bool(node, "OTR/automatic"); *onlyprivatep = purple_blist_node_get_bool(node, "OTR/onlyprivate"); *avoidloggingotrp = purple_blist_node_get_bool(node, "OTR/avoidloggingotr"); } }
void rc_pop_contacts(PurpleGroup * grp) { if (!grp) return; PurpleBlistNode * gnode = PURPLE_BLIST_NODE(grp); PurpleBlistNode * n = NULL; PurpleBuddy * b = NULL; int total; gboolean offline; //XXX group->totalsize is unreliable!!! for (n=gnode->child, total=0; n!=NULL; total++, n=n->next); trace("Total Group Count %d", total); while (total > g_size) { n = gnode->child; if (PURPLE_BLIST_NODE_IS_CONTACT(n)) { trace("Child Contact : %s", (PURPLE_CONTACT(n)->priority->name)); b = PURPLE_CONTACT(n)->priority; } else if (PURPLE_BLIST_NODE_IS_BUDDY(n)) { trace("Child Buddy : %s", (PURPLE_BUDDY(n)->name)); b = PURPLE_BUDDY(n); } n = PURPLE_BLIST_NODE(b); const char *name = purple_blist_node_get_string(n, NODE_GROUP_KEY); if (!name) { // if cannot find orig group name, put back to Buddies trace("ERROR!!! cannot find original group name"); name = "Buddies"; } PurpleGroup * g = purple_find_group(name); if (!g) { trace("Group %s Not Found. Create one.", name); g = purple_group_new(name); } trace("<<<<<<< Remove %s", b->name); offline = purple_blist_node_get_bool(n, NODE_ORIG_OFFLINE_KEY); purple_blist_node_set_bool(n, NODE_OFFLINE_KEY, offline); purple_blist_add_buddy(b, NULL, g, NULL); total--; } }
void PurpleLine::tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full) { purple_notify_user_info_add_pair_plaintext(user_info, "Name", purple_buddy_get_alias(buddy)); //purple_notify_user_info_add_pair_plaintext(user_info, // "User ID", purple_buddy_get_name(buddy)); if (purple_blist_node_get_bool(PURPLE_BLIST_NODE(buddy), "official_account")) purple_notify_user_info_add_pair_plaintext(user_info, "Official account", "Yes"); if (PURPLE_BLIST_NODE_HAS_FLAG(buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE)) { // This breaks? //purple_notify_user_info_add_section_break(user_info); purple_notify_user_info_add_pair_plaintext(user_info, "Temporary", "You are currently in a conversation with this contact, " "but they are not on your friend list."); } }
void rc_push_contact(PurpleAccount *acct, const char * buddyname) { PurpleGroup * grp = purple_find_group(GROUP_NAME); if (!grp) { trace("Group %s Not Found. Create one.", GROUP_NAME); grp = purple_group_new(GROUP_NAME); } PurpleBuddy * buddy; // if we can find it in 'Recent Contacts', skip if ((buddy = purple_find_buddy_in_group(acct, buddyname, grp)) != NULL) { trace("Buddy %s is already in %s", buddyname, GROUP_NAME); purple_blist_add_buddy(buddy, NULL, grp, NULL); return; } buddy = purple_find_buddy(acct, buddyname); if (!buddy) { trace("Buddy %s Not Found. You SUCK!", buddyname); return; } PurpleBlistNode * node = PURPLE_BLIST_NODE(buddy); // back up group info PurpleGroup * orig_grp = purple_buddy_get_group(buddy); purple_blist_node_set_string(node, NODE_GROUP_KEY, orig_grp->name); // back up offline info gboolean offline = purple_blist_node_get_bool(node, NODE_OFFLINE_KEY); purple_blist_node_set_bool(node, NODE_ORIG_OFFLINE_KEY, offline); purple_blist_node_set_bool(node, NODE_OFFLINE_KEY, TRUE); // Add to Recent Contacts Group trace(">>>>>>> Add %s", buddyname); purple_blist_add_buddy(buddy, NULL, grp, NULL); // Clean up old group if needed rc_pop_contacts(grp); }
static gboolean close_conv_cb(GtkButton *button, PidginConversation *gtkconv) { /* We are going to destroy the conversations immediately only if the 'close immediately' * preference is selected. Otherwise, close the conversation after a reasonable timeout * (I am going to consider 10 minutes as a 'reasonable timeout' here. * For chats, close immediately if the chat is not in the buddylist, or if the chat is * not marked 'Persistent' */ PurpleConversation *conv = gtkconv->active_conv; PurpleAccount *account = purple_conversation_get_account(conv); const char *name = purple_conversation_get_name(conv); switch (purple_conversation_get_type(conv)) { case PURPLE_CONV_TYPE_IM: { if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/close_immediately")) close_this_sucker(gtkconv); else hide_conv(gtkconv, TRUE); break; } case PURPLE_CONV_TYPE_CHAT: { PurpleChat *chat = purple_blist_find_chat(account, name); if (!chat || !purple_blist_node_get_bool(&chat->node, "gtk-persistent")) close_this_sucker(gtkconv); else hide_conv(gtkconv, FALSE); break; } default: ; } return TRUE; }
static char *plus_nick_changed_cb(PurpleBuddy *buddy) { char * ret = NULL; gboolean setting; purple_debug_misc("plusblist","Screename is \"%s\", server alias is \"%s\"\n",buddy->name,buddy->server_alias); setting = purple_blist_node_get_bool(&buddy->node, "disable_plus"); if(!setting) { /* get an escaped version of the alias */ char *esc, *p; GString *buf; int gradientIndexFG, gradientIndexBG, ncharsFG, ncharsBG; int begColorFG[3], endColorFG[3], deltaColorFG[3]; int begColorBG[3], endColorBG[3], deltaColorBG[3]; unsigned char gradientBG, gradientFG, insideTag; /* Colorization on alias, if set. */ if (buddy->alias != NULL) esc = g_strdup(buddy->alias); else esc = g_strdup(buddy->server_alias); purple_debug_misc("plusblist","Parsing tags to \"%s\"\n",esc); if(!esc) return NULL; /* oops... */ gradientBG = gradientFG = insideTag = FALSE; ncharsBG = ncharsFG = gradientIndexBG = gradientIndexFG = 0; p = esc; /* Ciclo di lettura caratteri */ buf = g_string_new(""); for (;*p;p = g_utf8_next_char(p)) { if (*p == '[') { /* Controllo tag */ /* Faccio un fast forward per cercare il corrispondente ], * determinando quindi se si tratta di un tag oppure no. */ int i; for(i = 1; i < 12; i++) { if (p[i] == ']') { char *replace; char tagCharLowerCase, tagCharUpperCase; char gradientTag = FALSE; /* Ho trovato la fine del tag, sono dentro! */ /* Controllo gradiente */ /* Try to unificate c/a*/ tagCharLowerCase = tagCharUpperCase = 0; if (p[1] == 'c' || p[1] == 'C') { tagCharLowerCase = 'c'; tagCharUpperCase = 'C'; } else if (p[1] == 'a' || p[1] == 'A') { tagCharLowerCase = 'a'; tagCharUpperCase = 'A'; } else if (p[1] == 'b' || p[1] == 'B' || p[1] == 'i' || p[1] == 'I' || p[1] == 'u' || p[1] == 'U' || p[1] == 's' || p[1] == 'S' || p[1] == '/') { /* sarebbe carino fargli skippare la parte di controllo gradiente */ } else { break; } insideTag = TRUE; if ((p[1] == tagCharLowerCase || p[1] == tagCharUpperCase) && p[2] == '=') { gchar *iter = p + i + 1; char insideTagFastForward = FALSE; int fastForwardCharCounter = 0; if (tagCharLowerCase == 'c') { gradientFG = FALSE; /* TODO: necessario? */ ncharsFG = 0; } else { gradientBG = FALSE; /* TODO: necessario? */ ncharsBG = 0; } /* Vado avanti e cerco il finale corrispondente */ for (;*iter;iter = g_utf8_next_char(iter)) { if (iter[0] == '[' && iter[1] == '/' && (iter[2] == tagCharLowerCase || iter[2] == tagCharUpperCase) ) { purple_debug_misc("plusblist", "Gradient end found.\n"); if (iter[3] == '=') { char *initialColor, *finalColor; int j; gradientTag = TRUE; /* */ initialColor = findColor(p + 3); finalColor = findColor(iter + 4); if (!initialColor || !finalColor) break; purple_debug_misc("plusblist", "Beginning color: %s\n", initialColor); for (j = 0;j <= 2;j++) { if (tagCharLowerCase == 'c') { begColorFG[j] = hexDec(initialColor + 2 * j, 2); endColorFG[j] = hexDec(finalColor + 2 * j, 2); deltaColorFG[j] = endColorFG[j] - begColorFG[j]; } else { begColorBG[j] = hexDec(initialColor + 2 * j, 2); endColorBG[j] = hexDec(finalColor + 2 * j, 2); deltaColorBG[j] = endColorBG[j] - begColorBG[j]; } } purple_debug_misc("plusblist", "Ending color: %s\n", finalColor); g_free(initialColor); g_free(finalColor); if (tagCharLowerCase == 'c') { gradientFG = TRUE; gradientIndexFG = 0; purple_debug_misc("plusblist", "Number of chars inside the gradient: %i\n", ncharsFG); } else { gradientBG = TRUE; gradientIndexBG = 0; purple_debug_misc("plusblist", "Number of chars inside the gradient: %i\n", ncharsBG); } /* Calcolare il numero di caratteri effettivi (escludendo i tag), * e suddividere il Delta R, G, B diviso il numero di caratteri, * ottenendo l'incremento da aggiungere (o sottrarre) * ad ogni carattere. * Subito PRIMA dell'ultimo carattere, mettere il colore finale. */ } break; } else { if (tagCharLowerCase == 'c') ncharsFG++; else ncharsBG++; } if (iter[0] == '[') { /* sono FORSE all'interno di un tag*/ if (iter[1] == 'b' || iter[1] == 'B' || iter[1] == 'i' || iter[1] == 'I' || iter[1] == 'u' || iter[1] == 'U' || iter[1] == 's' || iter[1] == 'S' || iter[1] == 'a' || iter[1] == 'A' || iter[1] == 'c' || iter[1] == 'C' || iter[1] == '/') { insideTagFastForward = TRUE; /* TODO: non e' vero, limite massimo caratteri */ fastForwardCharCounter = 0; } } else if (iter[0] == ']' && insideTagFastForward) { /* ero all'interno di un tag ed ora l'ho chiuso */ insideTagFastForward = FALSE; if (tagCharLowerCase == 'c') ncharsFG -= (fastForwardCharCounter + 2); /* 2 = squares []*/ else ncharsBG -= (fastForwardCharCounter + 2); /* 2 = squares []*/ } else if (insideTagFastForward) { fastForwardCharCounter++; } } } /* fine controllo gradiente */ /* Non devo tradurre il tag di fine gradiente: */ if (p[1] == '/' && p[3] == '=') { gradientTag = TRUE; if (tagCharLowerCase == 'c') gradientFG = FALSE; else if (tagCharLowerCase == 'a') gradientBG = FALSE; } /* Tag convertito ed aggiunto solo se non sono in un gradiente. * Infatti in questo caso viene gestito dopo. */ if (!gradientTag) { purple_debug_misc("plusblist", "Translating tag %s\n", g_strndup(p + 1, i - 1)); replace = convert_tag(g_strndup(p + 1, i - 1)); if (replace) { g_string_append(buf, replace); } g_free(replace); } break; /* Ne ho trovata una, non cerco le seguenti. */ } /* Fine if p = ] */ } /* Fine ciclo for per cercare la fine del tag ] */ } else if (*p == ']' && insideTag) { insideTag = FALSE; continue; } if (!insideTag) { /* Get the next character (using utf-8) */ gchar *thischar_unescaped, *thischar; thischar_unescaped = g_new0(char, 10); g_utf8_strncpy(thischar_unescaped, p, 1); thischar = g_markup_escape_text(thischar_unescaped, -1); g_free(thischar_unescaped); if (gradientFG || gradientBG) { /* Aggiungo i caratteri colorati del gradiente */ int j; int color[3]; char *tag, *fgAttribute = NULL, *bgAttribute = NULL; if (gradientFG) { for (j = 0; j <= 2; j++) { int delta = 0; if (ncharsFG > 1) delta = deltaColorFG[j] * gradientIndexFG / (ncharsFG - 1); color[j] = begColorFG[j] + delta; } fgAttribute = g_strdup_printf(" foreground=\"#%02x%02x%02x\"", color[0], color[1], color[2]); } else fgAttribute = g_strdup(""); if (gradientBG) { for (j = 0; j <= 2; j++) { int delta = 0; if (ncharsBG > 1) delta = deltaColorBG[j] * gradientIndexBG / (ncharsBG - 1); color[j] = begColorBG[j] + delta; } bgAttribute = g_strdup_printf(" background=\"#%02x%02x%02x\"", color[0], color[1], color[2]); } else bgAttribute = g_strdup(""); tag = g_strdup_printf("<span%s%s>%s</span>", fgAttribute, bgAttribute, thischar); g_free(fgAttribute); g_free(bgAttribute); g_string_append(buf, tag); g_free(tag); if (gradientFG) gradientIndexFG++; if (gradientBG) gradientIndexBG++; if (gradientIndexFG >= ncharsFG) gradientFG = FALSE; if (gradientIndexBG >= ncharsBG) gradientBG = FALSE; } else { /* Carattere normale, senza essere in un gradiente */ g_string_append(buf, thischar); } g_free(thischar); } }
static gboolean ggp_roster_is_synchronized(PurpleBuddy *buddy) { gboolean ret = purple_blist_node_get_bool(PURPLE_BLIST_NODE(buddy), GGP_ROSTER_SYNC_SETT); return ret; }