Bug 1213908 - Add support for setting buddyIcon and getting participant with nick in MUCs, purple part. r=aleth,florian
authorAbdelrhman Ahmed <a.ahmed1026@gmail.com>
Sat, 24 Oct 2015 14:38:00 +0200
changeset 781 d18b0bddc4f8190e1bc07576e018557bd38b5150
parent 780 7f82a8aa600d0e94f6e2b69919844835878da8d4
child 782 17fc639a64bdf4a481068e2e91b54f3de8de5d3e
push id57
push useraleth@instantbird.org
push dateThu, 29 Oct 2015 23:21:24 +0000
reviewersaleth, florian
bugs1213908
Bug 1213908 - Add support for setting buddyIcon and getting participant with nick in MUCs, purple part. r=aleth,florian
purplexpcom/src/purpleConvChat.cpp
purplexpcom/src/purpleConvChatBuddy.cpp
--- a/purplexpcom/src/purpleConvChat.cpp
+++ b/purplexpcom/src/purpleConvChat.cpp
@@ -69,16 +69,35 @@ NS_IMETHODIMP purpleConvChat::SendMsg(co
   purpleAccountScoper scoper(purpleConversation::GetAccount());
   PromiseFlatCString flatMsg(aMsg);
   purple_conv_chat_send(mConv->u.chat, flatMsg.get());
   LOG(("chat message sent: %s", flatMsg.get()));
 
   return NS_OK;
 }
 
+/* prplIConvChatBuddy getParticipant(in AUTF8String aName); */
+NS_IMETHODIMP purpleConvChat::GetParticipant(const nsACString & aName,
+                                             prplIConvChatBuddy **aResult)
+{
+  NS_ENSURE_TRUE(mConv, NS_ERROR_NOT_INITIALIZED);
+
+  PurpleConvChat *chat = purple_conversation_get_chat_data(mConv);
+  NS_ENSURE_TRUE(chat, NS_ERROR_FAILURE);
+
+  PurpleConvChatBuddy *cb =
+    purple_conv_chat_cb_find(chat, PromiseFlatCString(aName).get());
+  if (cb) {
+    purpleConvChatBuddy *participant = new purpleConvChatBuddy();
+    participant->Init(cb);
+    NS_ADDREF(*aResult = static_cast<prplIConvChatBuddy *>(participant));
+  }
+  return NS_OK;
+}
+
 /* nsISimpleEnumerator GetParticipants (); */
 NS_IMETHODIMP purpleConvChat::GetParticipants(nsISimpleEnumerator **_retval)
 {
   NS_ENSURE_TRUE(mConv, NS_ERROR_NOT_INITIALIZED);
   LOG(("GetParticipants of conversation with id %i", mId));
 
   PurpleConvChat *chat = purple_conversation_get_chat_data(mConv);
   NS_ENSURE_TRUE(chat, NS_ERROR_FAILURE);
--- a/purplexpcom/src/purpleConvChatBuddy.cpp
+++ b/purplexpcom/src/purpleConvChatBuddy.cpp
@@ -52,16 +52,24 @@ NS_IMETHODIMP purpleConvChatBuddy::GetAl
 
 /* readonly attribute boolean buddy; */
 NS_IMETHODIMP purpleConvChatBuddy::GetBuddy(bool *aBuddy)
 {
   *aBuddy = mBuddy;
   return NS_OK;
 }
 
+/* readonly attribute AUTF8String buddyIconURI; */
+NS_IMETHODIMP
+purpleConvChatBuddy::GetBuddyIconFilename(nsACString & aBuddyURI)
+{
+  // This method is not supported by libpurple.
+  aBuddyURI = "";
+  return NS_OK;
+}
 
 /* Get flag from PurpleConvChatBuddyFlags */
 #define PURPLE_IMPL_GETFLAG(aName, aFlag)                               \
   NS_IMETHODIMP purpleConvChatBuddy::Get##aName(bool *a##aName)         \
   {                                                                     \
     *a##aName = (mFlags & PURPLE_CBFLAGS_##aFlag) ? PR_TRUE : PR_FALSE; \
     return NS_OK;                                                       \
   }