comparison libpurple/protocols/msn/msn.c @ 25553:7f8cf35fc99b

propagate from branch 'im.pidgin.pidgin' (head c323420a0b3b17b1eba64763c01038ddf05ff0c2) to branch 'im.pidgin.pidgin.yaz' (head 3dc04de4d17fdd9333be36950cfe86115e1b48a5)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 28 Aug 2007 09:20:27 +0000
parents ff69c2a9ccf2 d9d9283680a4
children 26f55eb6ab59
comparison
equal deleted inserted replaced
25543:5e76304ebcc8 25553:7f8cf35fc99b
98 g_free(tmp); 98 g_free(tmp);
99 99
100 return buf; 100 return buf;
101 } 101 }
102 102
103 static gboolean
104 msn_send_attention(PurpleConnection *gc, const char *username, guint type)
105 {
106 MsnMessage *msg;
107 MsnSession *session;
108 MsnSwitchBoard *swboard;
109
110 msg = msn_message_new_nudge();
111 session = gc->proto_data;
112 swboard = msn_session_get_swboard(session, username, MSN_SB_FLAG_IM);
113
114 if (swboard == NULL)
115 return FALSE;
116
117 msn_switchboard_send_msg(swboard, msg, TRUE);
118
119 return TRUE;
120 }
121
122 #ifdef MSN_USE_ATTENTION_API
123 static GList *
124 msn_attention_types(PurpleAccount *account)
125 {
126 PurpleAttentionType *attn;
127 static GList *list = NULL;
128
129 if (!list) {
130 attn = g_new0(PurpleAttentionType, 1);
131 attn->name = _("nudge");
132 attn->incoming_description = _("nudged");
133 attn->outgoing_description = _("Nudging");
134 list = g_list_append(list, attn);
135 }
136
137 return list;
138 }
139 #endif
140
141
103 static PurpleCmdRet 142 static PurpleCmdRet
104 msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) 143 msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
105 { 144 {
106 PurpleAccount *account = purple_conversation_get_account(conv); 145 PurpleAccount *account = purple_conversation_get_account(conv);
107 PurpleConnection *gc = purple_account_get_connection(account); 146 PurpleConnection *gc = purple_account_get_connection(account);
108 MsnMessage *msg; 147 const gchar *username;
109 MsnSession *session; 148
110 MsnSwitchBoard *swboard; 149 username = purple_conversation_get_name(conv);
111 150
112 msg = msn_message_new_nudge(); 151 #ifdef MSN_USE_ATTENTION_API
113 session = gc->proto_data; 152 serv_send_attention(gc, username, MSN_NUDGE);
114 swboard = msn_session_get_swboard(session, purple_conversation_get_name(conv), MSN_SB_FLAG_IM); 153 #else
115 154 if (!msn_send_attention(gc, username, MSN_NUDGE))
116 if (swboard == NULL)
117 return PURPLE_CMD_RET_FAILED; 155 return PURPLE_CMD_RET_FAILED;
118 156
119 msn_switchboard_send_msg(swboard, msg, TRUE);
120
121 purple_conversation_write(conv, NULL, _("You have just sent a Nudge!"), PURPLE_MESSAGE_SYSTEM, time(NULL)); 157 purple_conversation_write(conv, NULL, _("You have just sent a Nudge!"), PURPLE_MESSAGE_SYSTEM, time(NULL));
158 #endif
122 159
123 return PURPLE_CMD_RET_OK; 160 return PURPLE_CMD_RET_OK;
124 } 161 }
125 162
126 static void 163 static void
2125 msn_offline_message, /* offline_message */ 2162 msn_offline_message, /* offline_message */
2126 NULL, /* whiteboard_prpl_ops */ 2163 NULL, /* whiteboard_prpl_ops */
2127 NULL, /* send_raw */ 2164 NULL, /* send_raw */
2128 NULL, /* roomlist_room_serialize */ 2165 NULL, /* roomlist_room_serialize */
2129 2166
2167 #ifdef MSN_USE_ATTENTION_API
2168 msn_send_attention, /* send_attention */
2169 msn_attention_types, /* attention_types */
2170 #else
2130 /* padding */ 2171 /* padding */
2131 NULL, 2172 NULL,
2132 NULL, 2173 NULL,
2174 #endif
2133 NULL, 2175 NULL,
2134 NULL 2176 NULL
2135 }; 2177 };
2136 2178
2137 static PurplePluginInfo info = 2179 static PurplePluginInfo info =