static void notify_buddy_signoff_cb (PurpleBuddy *buddy, gpointer data) { gchar *tr_name, *title; gboolean blocked; g_return_if_fail (buddy); if (!purple_prefs_get_bool ("/plugins/gtk/libnotify/signoff")) return; if (g_list_find (just_signed_on_accounts, buddy->account)) return; blocked = purple_prefs_get_bool ("/plugins/gtk/libnotify/blocked"); if (!purple_privacy_check (buddy->account, buddy->name) && blocked) return; if (!should_notify_unavailable (purple_buddy_get_account (buddy))) return; tr_name = truncate_escape_string (best_name (buddy), 25); title = g_strdup_printf (_("%s signed off"), tr_name); notify (title, NULL, buddy, NULL); g_free (tr_name); g_free (title); }
void yahoo_process_conference_decline(PurpleConnection *gc, struct yahoo_packet *pkt) { GSList *l; char *room = NULL; char *who = NULL; char *msg = NULL; PurpleConversation *c = NULL; int utf8 = 0; for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 57: g_free(room); room = yahoo_string_decode(gc, pair->value, FALSE); break; case 54: who = pair->value; break; case 14: g_free(msg); msg = yahoo_string_decode(gc, pair->value, FALSE); break; case 97: utf8 = strtol(pair->value, NULL, 10); break; } } if (!purple_privacy_check(purple_connection_get_account(gc), who)) { g_free(room); g_free(msg); return; } if (who && room) { /* make sure we're in the room before we process a decline message for it */ if((c = yahoo_find_conference(gc, room))) { char *tmp = NULL, *msg_tmp = NULL; if(msg) { msg_tmp = yahoo_string_decode(gc, msg, utf8); msg = yahoo_codes_to_html(msg_tmp); serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(c)), who, 0, msg, time(NULL)); g_free(msg_tmp); g_free(msg); } tmp = g_strdup_printf(_("%s has declined to join."), who); purple_conversation_write(c, NULL, tmp, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LINKIFY, time(NULL)); g_free(tmp); } g_free(room); } }
void yahoo_process_chat_addinvite(PurpleConnection *gc, struct yahoo_packet *pkt) { PurpleAccount *account; GSList *l; char *room = NULL; char *msg = NULL; char *who = NULL; account = purple_connection_get_account(gc); for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 104: g_free(room); room = yahoo_string_decode(gc, pair->value, TRUE); break; case 129: /* room id? */ break; case 126: /* ??? */ break; case 117: g_free(msg); msg = yahoo_string_decode(gc, pair->value, FALSE); break; case 119: who = pair->value; break; case 118: /* us */ break; } } if (room && who) { GHashTable *components; if (!purple_privacy_check(account, who) || (purple_account_get_bool(account, "ignore_invites", FALSE))) { purple_debug_info("yahoo", "Invite to room %s from %s has been dropped.\n", room, who); g_free(room); g_free(msg); return; } components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); g_hash_table_replace(components, g_strdup("room"), g_strdup(room)); serv_got_chat_invite(gc, room, who, msg, components); } g_free(room); g_free(msg); }
static int purplemot_send_im(PurpleConnection *gc, const char *who, const char *message, PurpleMessageFlags flags) { const char *from_username = gc->account->username; PurpleMessageFlags receive_flags = ((flags & ~PURPLE_MESSAGE_SEND) | PURPLE_MESSAGE_RECV); PurpleAccount *to_acct = purple_accounts_find(who, PURPLEMOT_ID); PurpleConnection *to; purple_debug_info("purplemot", "sending message from %s to %s: %s\n", from_username, who, message); /* is the sender blocked by the recipient's privacy settings? */ if (to_acct && !purple_privacy_check(to_acct, gc->account->username)) { char *msg = g_strdup_printf( _("Your message was blocked by %s's privacy settings."), who); purple_debug_info("purplemot", "discarding; %s is blocked by %s's privacy settings\n", from_username, who); purple_conv_present_error(who, gc->account, msg); g_free(msg); return 0; } /* is the recipient online? */ to = get_purplemot_gc(who); if (to) { /* yes, send */ serv_got_im(to, from_username, message, receive_flags, time(NULL)); } else { /* nope, store as an offline message */ GOfflineMessage *offline_message; GList *messages; purple_debug_info("purplemot", "%s is offline, sending as offline message\n", who); offline_message = g_new0(GOfflineMessage, 1); offline_message->from = g_strdup(from_username); offline_message->message = g_strdup(message); offline_message->mtime = time(NULL); offline_message->flags = receive_flags; messages = g_hash_table_lookup(goffline_messages, who); messages = g_list_append(messages, offline_message); g_hash_table_insert(goffline_messages, g_strdup(who), messages); } return 1; }
static void buddy_typing_cb(PurpleAccount *acct, const char *name, void *data) { PurpleConversation *gconv; if(purple_prefs_get_bool(PREF_STATUS) && ! purple_status_is_available(purple_account_get_active_status(acct))) { purple_debug_info("psychic", "not available, doing nothing\n"); return; } if(purple_prefs_get_bool(PREF_BUDDIES) && ! purple_find_buddy(acct, name)) { purple_debug_info("psychic", "not in blist, doing nothing\n"); return; } if(FALSE == purple_privacy_check(acct, name)) { purple_debug_info("psychic", "user %s is blocked\n", name); return; } gconv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, acct); if(! gconv) { purple_debug_info("psychic", "no previous conversation exists\n"); gconv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, name); if(purple_prefs_get_bool(PREF_RAISE)) { purple_conversation_present(gconv); } if(purple_prefs_get_bool(PREF_NOTICE)) { /* This is a quote from Star Wars. You should probably not translate it literally. If you can't find a fitting cultural reference in your language, consider translating something like this instead: "You feel a new message coming." */ purple_conversation_write(gconv, NULL, _("You feel a disturbance in the force..."), PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_ACTIVE_ONLY, time(NULL)); } /* Necessary because we may be creating a new conversation window. */ purple_conv_im_set_typing_state(PURPLE_CONV_IM(gconv), PURPLE_TYPING); } }
static void notify_msg_sent (PurpleAccount *account, PurpleConversation *conv, const gchar *sender, const gchar *message) { PurpleBuddy *buddy; gchar *title, *body, *tr_name; gboolean blocked; blocked = purple_prefs_get_bool ("/plugins/gtk/libnotify/blocked"); if (blocked && !purple_privacy_check(account, sender)) return; buddy = purple_find_buddy (account, sender); if (buddy) tr_name = truncate_escape_string (best_name (buddy), 25); else if (conv) { char *name = g_strdup_printf (_("%s (%s)"), sender, purple_conversation_get_name (conv)); tr_name = truncate_escape_string (name, 25); g_free (name); } else tr_name = truncate_escape_string (sender, 25); if (purple_prefs_get_bool("/plugins/gtk/libnotify/newmsgtxt")) { title = g_strdup_printf (_("%s says:"), tr_name); body = purple_markup_strip_html (message); notify (title, body, buddy, conv); g_free (title); } else { title = _("new message received"); body = g_strdup_printf (_("from %s"), tr_name); notify (title, body, buddy, conv); } g_free (tr_name); g_free (body); }
void yahoo_process_picture(PurpleConnection *gc, struct yahoo_packet *pkt) { YahooData *yd; GSList *l = pkt->hash; char *who = NULL; gboolean got_icon_info = FALSE, send_icon_info = FALSE; char *url = NULL; int checksum = 0; while (l) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 1: case 4: if (g_utf8_validate(pair->value, -1, NULL)) { who = pair->value; } else { purple_debug_warning("yahoo", "yahoo_process_picture " "got non-UTF-8 string for key %d\n", pair->key); } break; case 5: /* us */ break; case 13: { int tmp; tmp = strtol(pair->value, NULL, 10); if (tmp == 1) { send_icon_info = TRUE; } else if (tmp == 2) { got_icon_info = TRUE; } break; } case 20: if (g_utf8_validate(pair->value, -1, NULL)) { url = pair->value; } else { purple_debug_warning("yahoo", "yahoo_process_picture " "got non-UTF-8 string for key %d\n", pair->key); } break; case 192: checksum = strtol(pair->value, NULL, 10); break; } l = l->next; } if (!who) return; if (!purple_privacy_check(purple_connection_get_account(gc), who)) { purple_debug_info("yahoo", "Picture packet from %s dropped.\n", who); return; } /* Yahoo IM 6 spits out 0.png as the URL if the buddy icon is not set */ if (who && got_icon_info && url && !g_ascii_strncasecmp(url, "http://", 7)) { /* TODO: make this work p2p, try p2p before the url */ PurpleUtilFetchUrlData *url_data; struct yahoo_fetch_picture_data *data; /* use whole URL if using HTTP Proxy */ gboolean use_whole_url = yahoo_account_use_http_proxy(gc); data = g_new0(struct yahoo_fetch_picture_data, 1); data->gc = gc; data->who = g_strdup(who); data->checksum = checksum; /* TODO: Does this need to be MSIE 5.0? */ url_data = purple_util_fetch_url(url, use_whole_url, "Mozilla/4.0 (compatible; MSIE 5.5)", FALSE, yahoo_fetch_picture_cb, data); if (url_data != NULL) { yd = gc->proto_data; yd->url_datas = g_slist_prepend(yd->url_datas, url_data); } } else if (who && send_icon_info) {
void yahoo_process_conference_invite(PurpleConnection *gc, struct yahoo_packet *pkt) { PurpleAccount *account; GSList *l; char *room = NULL; char *who = NULL; char *msg = NULL; GString *members = NULL; GHashTable *components; if ( (pkt->status == 2) || (pkt->status == 11) ) return; /* Status is 11 when we are being notified about invitation being sent to someone else */ account = purple_connection_get_account(gc); for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; if (pair->key == 57) { room = yahoo_string_decode(gc, pair->value, FALSE); if (yahoo_find_conference(gc, room) != NULL) { /* Looks like we got invited to an already open conference. */ /* Laters: Should we accept this conference rather than ignoring the invitation ? */ purple_debug_info("yahoo","Ignoring invitation for an already existing chat, room:%s\n",room); g_free(room); return; } } } members = g_string_sized_new(512); for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 1: /* us, but we already know who we are */ break; case 57: g_free(room); room = yahoo_string_decode(gc, pair->value, FALSE); break; case 50: /* inviter */ who = pair->value; g_string_append_printf(members, "%s\n", who); break; case 51: /* This user is being invited to the conference. Comes with status = 11, so we wont reach here */ break; case 52: /* Invited users. Assuming us invited, since we got this packet */ break; /* break needed, or else we add the users to the conference before they accept the invitation */ case 53: /* members who have already joined the conference */ g_string_append_printf(members, "%s\n", pair->value); break; case 58: g_free(msg); msg = yahoo_string_decode(gc, pair->value, FALSE); break; case 13: /* ? */ break; } } if (!room) { g_string_free(members, TRUE); g_free(msg); return; } if (!purple_privacy_check(account, who) || (purple_account_get_bool(account, "ignore_invites", FALSE))) { purple_debug_info("yahoo", "Invite to conference %s from %s has been dropped.\n", room, who); g_free(room); g_free(msg); g_string_free(members, TRUE); return; } components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); g_hash_table_replace(components, g_strdup("room"), room); if (msg) g_hash_table_replace(components, g_strdup("topic"), msg); g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); g_hash_table_replace(components, g_strdup("members"), g_string_free(members, FALSE)); serv_got_chat_invite(gc, room, who, msg, components); }