/*------------------------------------------------------------------------ * User has entered a message in a chatroom window, send it to the MXit server. * * @param gc The connection object * @param id The chat room ID * @param message The sent message data * @param flags The message flags * @return Indicates success / failure */ int mxit_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) { struct MXitSession* session = (struct MXitSession*) gc->proto_data; struct multimx* multimx = NULL; const char* nickname; purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i message send: '%s'\n", id, message); /* Find matching MultiMX group */ multimx = find_room_by_id(session, id); if (multimx == NULL) { purple_debug_error(MXIT_PLUGIN_ID, "Could not find groupchat %i\n", id); return -1; } /* Send packet to MXit */ mxit_send_message(session, multimx->roomid, message, TRUE, FALSE); /* Determine our nickname to display */ if (multimx->nickname) nickname = multimx->nickname; else nickname = purple_account_get_alias(purple_connection_get_account(gc)); /* local alias */ /* Display message in chat window */ serv_got_chat_in(gc, id, nickname, flags, message, time(NULL)); return 0; }
void AccountWindow::StringOption::updateValue() { if (type == TYPE_PASSWORD) { setMasked(true); setValue(purple_account_get_password(account)); } else if (type == TYPE_ALIAS) setValue(purple_account_get_alias(account)); else setValue(purple_account_get_string(account, purple_account_option_get_setting(option), purple_account_option_get_default_string(option))); }
static void fb_set_status_cb(PurplePluginAction *action) { PurpleConnection *pc = action->context; FacebookAccount *fba = pc->proto_data; gchar *uid_str; uid_str = g_strdup_printf("%" G_GINT64_FORMAT, fba->uid); purple_request_input(pc, NULL, _("Set your Facebook status"), purple_account_get_alias(pc->account), "is ", FALSE, FALSE, NULL, _("OK"), G_CALLBACK(fb_set_status_ok_cb), _("Cancel"), NULL, pc->account, uid_str, NULL, pc); g_free(uid_str); }
void QuetzalAccount::save() { if (m_isLoading) return; // Test it else return; Config cfg = config(); cfg.beginGroup(QLatin1String("general")); cfg.setValue(QLatin1String("alias"), purple_account_get_alias(m_account)); cfg.setValue(QLatin1String("userInfo"), purple_account_get_user_info(m_account)); if (purple_account_get_remember_password(m_account)) cfg.setValue(QLatin1String("passwd"), purple_account_get_password(m_account), Config::Crypted); else cfg.remove(QLatin1String("passwd")); QVariantMap settings; g_hash_table_foreach(m_account->settings, (GHFunc)quetzal_serialize_node, &settings); cfg.setValue(QLatin1String("quetzal_settings"), settings); }
void flist_login(PurpleAccount *pa) { PurpleConnection *pc = purple_account_get_connection(pa); FListAccount *fla; gchar **ac_split; fla = g_new0(FListAccount, 1); fla->pa = pa; fla->pc = pc; fla->all_characters = g_hash_table_new_full((GHashFunc)flist_str_hash, (GEqualFunc)flist_str_equal, g_free, (GDestroyNotify)flist_character_free); fla->rx_buf = g_malloc0(256); fla->rx_len = 0; pc->proto_data = fla; ac_split = g_strsplit(purple_account_get_username(pa), ":", 2); fla->username = g_strdup(ac_split[0]); fla->character = g_strdup(ac_split[1]); fla->password = g_strdup(purple_account_get_password(pa)); //we don't want to display the whole username:character thing if(purple_account_get_alias(pa) == NULL || flist_str_equal(purple_account_get_username(pa), purple_account_get_alias(pa))) { purple_account_set_alias(pa, fla->character); } /* login options */ fla->server_address = g_strdup(purple_account_get_string(pa, "server_address", "chat.f-list.net")); fla->server_port = purple_account_get_int(pa, "server_port", FLIST_PORT); fla->sync_bookmarks = purple_account_get_bool(pa, "sync_bookmarks", FALSE); fla->sync_friends = purple_account_get_bool(pa, "sync_friends", TRUE); fla->debug_mode = purple_account_get_bool(pa, "debug_mode", FALSE); flist_channel_subsystem_load(fla); flist_clear_filter(fla); flist_global_kinks_load(pc); flist_profile_load(pc); flist_friends_load(fla); flist_ticket_timer(fla, 0); g_strfreev(ac_split); }
static void received_im_msg_cb(PurpleAccount *account, char *who, char *buffer, PurpleConversation *conv, PurpleMessageFlags flags, void *data) { // A workaround to avoid skipping of the first message as a result on NULL-conv: if (conv == NULL) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, who); PurpleBuddy *buddy = purple_find_buddy(account, who); PurplePresence *presence = purple_buddy_get_presence(buddy); msg_metadata_t msg; //Get message msg.text = purple_markup_strip_html(buffer); msg.remote_username = who; //LOCAL USER: msg.local_alias = purple_account_get_alias(account); msg.local_username = (char *) purple_account_get_name_for_display(account); //REMOTE USER (Buddy): //Get buddy alias msg.remote_alias = purple_buddy_get_alias(buddy); if(msg.remote_alias == NULL) msg.remote_alias = ""; //Get buddy group PurpleGroup *group = purple_buddy_get_group(buddy); //return empty string if not in group msg.remote_from_group = group != NULL ? purple_group_get_name(group) : ""; //Get protocol ID msg.protocol_id = purple_account_get_protocol_id(account); //trim out PROTOCOL_PREFIX (eg.: "prpl-irc" => "irc") if(!strncmp(msg.protocol_id,PROTOCOL_PREFIX,strlen(PROTOCOL_PREFIX))) msg.protocol_id += strlen(PROTOCOL_PREFIX); //Get status PurpleStatus *status = purple_account_get_active_status(account); PurpleStatusType *type = purple_status_get_type(status); //remote PurpleStatus *r_status = purple_presence_get_active_status(presence); PurpleStatusType *r_status_type = purple_status_get_type(r_status); //Get status id msg.local_status_id = NULL; msg.local_status_id = purple_primitive_get_id_from_type( purple_status_type_get_primitive(type)); //remote msg.remote_status_id = NULL; msg.remote_status_id = purple_primitive_get_id_from_type( purple_status_type_get_primitive(r_status_type)); //Get status message msg.local_status_msg = NULL; if (purple_status_type_get_attr(type, "message") != NULL) { msg.local_status_msg = purple_status_get_attr_string(status, "message"); } else { PurpleSavedStatus *savedstatus = purple_savedstatus_get_current(); if(savedstatus) msg.local_status_msg = purple_savedstatus_get_message(savedstatus); } //remote msg.remote_status_msg = NULL; if (purple_status_type_get_attr(r_status_type, "message") != NULL) { msg.remote_status_msg = purple_status_get_attr_string(r_status, "message"); } else { msg.remote_status_msg = ""; } run_lua(conv, msg); }
static int account_get_alias(LuaState *L)/*{{{*/ { PurpleAccount **account = ms_lua_checkclass(L, "purple.account", 1); lua_pushstring(L, purple_account_get_alias(*account)); return 1; }/*}}}*/
static void pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data) { PurpleConversation *conv; PurpleAccount *account; PurpleBuddy *buddy; const char *pouncee; const char *alias; pouncee = purple_pounce_get_pouncee(pounce); account = purple_pounce_get_pouncer(pounce); buddy = purple_find_buddy(account, pouncee); if (buddy != NULL) { alias = purple_buddy_get_alias(buddy); if (alias == NULL) alias = pouncee; } else alias = pouncee; if (purple_pounce_action_is_enabled(pounce, "open-window")) { if (!purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account)) purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); } if (purple_pounce_action_is_enabled(pounce, "popup-notify")) { char *tmp = NULL; const char *name_shown; const char *reason; struct { PurplePounceEvent event; const char *format; } messages[] = { {PURPLE_POUNCE_TYPING, _("%s has started typing to you (%s)")}, {PURPLE_POUNCE_TYPED, _("%s has paused while typing to you (%s)")}, {PURPLE_POUNCE_SIGNON, _("%s has signed on (%s)")}, {PURPLE_POUNCE_IDLE_RETURN, _("%s has returned from being idle (%s)")}, {PURPLE_POUNCE_AWAY_RETURN, _("%s has returned from being away (%s)")}, {PURPLE_POUNCE_TYPING_STOPPED, _("%s has stopped typing to you (%s)")}, {PURPLE_POUNCE_SIGNOFF, _("%s has signed off (%s)")}, {PURPLE_POUNCE_IDLE, _("%s has become idle (%s)")}, {PURPLE_POUNCE_AWAY, _("%s has gone away. (%s)")}, {PURPLE_POUNCE_MESSAGE_RECEIVED, _("%s has sent you a message. (%s)")}, {0, NULL} }; int i; reason = purple_pounce_action_get_attribute(pounce, "popup-notify", "reason"); /* * Here we place the protocol name in the pounce dialog to lessen * confusion about what protocol a pounce is for. */ for (i = 0; messages[i].format != NULL; i++) { if (messages[i].event & events) { tmp = g_strdup_printf(messages[i].format, alias, purple_account_get_protocol_name(account)); break; } } if (tmp == NULL) tmp = g_strdup(_("Unknown pounce event. Please report this!")); /* * Ok here is where I change the second argument, title, from * NULL to the account alias if we have it or the account * name if that's all we have */ if ((name_shown = purple_account_get_alias(account)) == NULL) name_shown = purple_account_get_username(account); if (reason == NULL) { purple_notify_info(NULL, name_shown, tmp, purple_date_format_full(NULL)); } else { char *tmp2 = g_strdup_printf("%s\n\n%s", reason, purple_date_format_full(NULL)); purple_notify_info(NULL, name_shown, tmp, tmp2); g_free(tmp2); } g_free(tmp); } if (purple_pounce_action_is_enabled(pounce, "send-message")) { const char *message; message = purple_pounce_action_get_attribute(pounce, "send-message", "message"); if (message != NULL) { conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account); if (conv == NULL) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); purple_conversation_write(conv, NULL, message, PURPLE_MESSAGE_SEND, time(NULL)); serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0); } } if (purple_pounce_action_is_enabled(pounce, "execute-command")) { const char *command; command = purple_pounce_action_get_attribute(pounce, "execute-command", "command"); if (command != NULL) { char *localecmd = g_locale_from_utf8(command, -1, NULL, NULL, NULL); if (localecmd != NULL) { int pid = fork(); if (pid == 0) { char *args[4]; args[0] = "sh"; args[1] = "-c"; args[2] = (char *)localecmd; args[3] = NULL; execvp(args[0], args); _exit(0); } g_free(localecmd); } } } if (purple_pounce_action_is_enabled(pounce, "play-beep")) { beep(); } }