soc.2009.transport: 26b9f581: Working chat_rename_user handler
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Wed Jun 10 07:21:16 EDT 2009
-----------------------------------------------------------------
Revision: 26b9f581f22ef2cb05f2b4caf0ce29181dc47d2f
Ancestor: 4d759a72c2b20cc526ba581afce473297d47fb74
Author: hanzz at soc.pidgin.im
Date: 2009-06-10T11:17:15
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/26b9f581f22ef2cb05f2b4caf0ce29181dc47d2f
Modified files:
main.cpp main.h muchandler.cpp muchandler.h user.cpp user.h
ChangeLog:
Working chat_rename_user handler
-------------- next part --------------
============================================================
--- main.cpp 4e21b7d59869e060b01e4565bb3cdd26cdbacac5
+++ main.cpp 108eb47ef7a67d21b07af57566162b7988c6213d
@@ -116,6 +116,10 @@ static void conv_chat_add_users(PurpleCo
GlooxMessageHandler::instance()->purpleChatAddUsers(conv, cbuddies, new_arrivals);
}
+static void conv_chat_rename_user(PurpleConversation *conv, const char *old_name, const char *new_name, const char *new_alias) {
+ GlooxMessageHandler::instance()->purpleChatRenameUser(conv, old_name, new_name, new_alias);
+}
+
/*
* Called when user is logged in...
*/
@@ -387,7 +391,7 @@ static PurpleConversationUiOps conversat
conv_write_im, /* write_im */
NULL,//pidgin_conv_write_conv, /* write_conv */
conv_chat_add_users, /* chat_add_users */
- NULL,//pidgin_conv_chat_rename_user, /* chat_rename_user */
+ conv_chat_rename_user, /* chat_rename_user */
NULL,//pidgin_conv_chat_remove_users, /* chat_remove_users */
NULL,//pidgin_conv_chat_update_user, /* chat_update_user */
NULL,//pidgin_conv_present_conversation, /* present */
@@ -902,6 +906,16 @@ void GlooxMessageHandler::purpleChatAddU
}
}
+void GlooxMessageHandler::purpleChatRenameUser(PurpleConversation *conv, const char *old_name, const char *new_name, const char *new_alias) {
+ PurpleAccount *account = purple_conversation_get_account(conv);
+ User *user = userManager()->getUserByAccount(account);
+ if (user) {
+ if (user->isConnected()){
+ user->purpleChatRenameUser(conv, old_name, new_name, new_alias);
+ }
+ }
+}
+
void GlooxMessageHandler::purpleBuddyChanged(PurpleBuddy* buddy){
if (buddy!=NULL){
PurpleAccount *a=purple_buddy_get_account(buddy);
============================================================
--- main.h 69af41e24073ad7b471a2d9263f3a5b565bd0b25
+++ main.h 715981f6a4a14711fcf38c11674faf5c410b1eb6
@@ -160,6 +160,7 @@ public:
void purpleConversationWriteIM(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime);
void purpleConversationWriteChat(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime);
void purpleChatAddUsers(PurpleConversation *conv, GList *cbuddies, gboolean new_arrivals);
+ void purpleChatRenameUser(PurpleConversation *conv, const char *old_name, const char *new_name, const char *new_alias);
void * purpleAuthorizeReceived(PurpleAccount *account,const char *remote_user,const char *id,const char *alias,const char *message,gboolean on_list,PurpleAccountRequestAuthorizationCb authorize_cb,PurpleAccountRequestAuthorizationCb deny_cb,void *user_data);
void purpleBuddyTyping(PurpleAccount *account, const char *who);
void purpleBuddyTypingStopped(PurpleAccount *account, const char *who);
============================================================
--- muchandler.cpp 49678e5ff434c0d77c3a5ac60c094a6bd2f89588
+++ muchandler.cpp e6929232eac44611025e73b3b5a7a7928e663ec3
@@ -74,7 +74,6 @@ void MUCHandler::addUsers(GList *cbuddie
x->addChild(item);
tag->addChild(x);
- std::cout << tag->xml() << "\n";
m_user->p->j->send(tag);
l = l->next;
@@ -92,3 +91,52 @@ void MUCHandler::messageReceived(const c
m_user->p->j->send( s );
}
+void MUCHandler::renameUser(const char *old_name, const char *new_name, const char *new_alias) {
+// <presence
+// from='darkcave at chat.shakespeare.lit/oldhag'
+// to='wiccarocks at shakespeare.lit/laptop'>
+// <x xmlns='http://jabber.org/protocol/muc#user'>
+// <item affiliation='member' role='participant'/>
+// </x>
+// </presence>
+ std::string oldName(old_name);
+ std::string newName(new_name);
+ Tag *tag = new Tag("presence");
+ tag->addAttribute("from", m_jid + "/" + oldName);
+ tag->addAttribute("to", m_userJid);
+ tag->addAttribute("type", "unavailable");
+
+ Tag *x = new Tag("x");
+ x->addAttribute("xmlns", "http://jabber.org/protocol/muc#user");
+
+ Tag *item = new Tag("item");
+ item->addAttribute("affiliation", "member");
+ item->addAttribute("role", "participant");
+ item->addAttribute("nick", newName);
+
+ Tag *status = new Tag("status");
+ status->addAttribute("code","303");
+
+ x->addChild(item);
+ x->addChild(status);
+ tag->addChild(x);
+ m_user->p->j->send(tag);
+
+
+ tag = new Tag("presence");
+ tag->addAttribute("from", m_jid + "/" + newName);
+ tag->addAttribute("to", m_userJid);
+
+ x = new Tag("x");
+ x->addAttribute("xmlns", "http://jabber.org/protocol/muc#user");
+
+ item = new Tag("item");
+ item->addAttribute("affiliation", "member");
+ item->addAttribute("role", "participant");
+
+ x->addChild(item);
+ tag->addChild(x);
+ m_user->p->j->send(tag);
+
+}
+
============================================================
--- muchandler.h e8462d50d90e4ce3bac61aeedd815947ee78eaea
+++ muchandler.h 8f104ea2e1ce45bf86a3013392f93b8cd2b1c19e
@@ -39,6 +39,7 @@ class MUCHandler
Tag * handlePresence(const Presence &stanza);
void addUsers(GList *cbuddies);
void messageReceived(const char *who, const char *msg, PurpleMessageFlags flags, time_t mtime);
+ void renameUser(const char *old_name, const char *new_name, const char *new_alias);
private:
User *m_user;
============================================================
--- user.cpp 1895a9ef5b54e7e5499ba2a0ed3556ac4ad1f6e9
+++ user.cpp 0db9c47147e31d935975f345427c37e67664eed0
@@ -547,6 +547,13 @@ void User::purpleChatAddUsers(PurpleConv
}
}
+void User::purpleChatRenameUser(PurpleConversation *conv, const char *old_name, const char *new_name, const char *new_alias) {
+ MUCHandler *muc = (MUCHandler*) g_hash_table_lookup(m_mucs, purple_conversation_get_name(conv));
+ if (muc) {
+ muc->renameUser(old_name, new_name, new_alias);
+ }
+}
+
/*
* Called when legacy network user stops typing.
*/
============================================================
--- user.h 58521a3f3f6c806d4956ff3dd406648709c1b784
+++ user.h 76cdabb3ee99a8aa9953f5c6be879a6d310a5c1f
@@ -92,6 +92,7 @@ class User {
void purpleMessageReceived(PurpleAccount* account,char * name,char *msg,PurpleConversation *conv,PurpleMessageFlags flags);
void purpleConversationWriteIM(PurpleConversation *conv, const char *who, const char *msg, PurpleMessageFlags flags, time_t mtime);
void purpleConversationWriteChat(PurpleConversation *conv, const char *who, const char *msg, PurpleMessageFlags flags, time_t mtime);
+ void purpleChatRenameUser(PurpleConversation *conv, const char *old_name, const char *new_name, const char *new_alias);
void purpleChatAddUsers(PurpleConversation *conv, GList *cbuddies, gboolean new_arrivals);
void purpleAuthorizeReceived(PurpleAccount *account,const char *remote_user,const char *id,const char *alias,const char *message,gboolean on_list,PurpleAccountRequestAuthorizationCb authorize_cb,PurpleAccountRequestAuthorizationCb deny_cb,void *user_data);
void purpleBuddyTypingStopped(const std::string &uin);
More information about the Commits
mailing list