Port things from MSN to WLM plugin:
[kdenetwork.git] / kopete / protocols / wlm / wlmlibmsn.cpp
blob3ea4885eb0cb8c7bec05cef8e2814cd19b05eb8f
1 /*
2 * msntest.cpp
3 * libmsn
5 * Created by Meredydd Luff.
6 * Refactored by Tiago Salem Herrmann
7 * Copyright (c) 2004 Meredydd Luff. All rights reserved.
8 * Copyright (c) 2007 Tiago Salem Herrmann. All rights reserved.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 // include first to not get compile errors on windows
26 #include <msn/msn.h>
28 #include <errno.h>
29 #include <sys/types.h>
30 #include <unistd.h>
31 #include <sys/stat.h>
32 #include <stdlib.h>
33 #include <string.h>
35 #include <sys/socket.h>
36 #include <arpa/inet.h>
37 #include <netinet/in.h>
38 #include <netdb.h>
39 #include <fcntl.h>
41 #include <msn/msn.h>
42 #include <string>
43 #include <iostream>
45 #include <QObject>
46 #include <QApplication>
47 #include <QPushButton>
48 #include <QList>
49 #include <QEventLoop>
50 #include <QSslSocket>
52 #include "kopetemessage.h"
53 #include "kopetecontact.h"
54 #include "kopeteuiglobal.h"
56 #include "wlmlibmsn.h"
57 #include "wlmserver.h"
58 #include "wlmaccount.h"
60 void
61 Callbacks::registerSocket (void *s, int reading, int writing, bool isSSL)
63 Q_UNUSED( writing );
64 Q_UNUSED( isSSL );
66 WlmSocket *a = (WlmSocket*)s;
67 if (!a)
68 return;
70 if (reading)
72 QObject::disconnect(a, SIGNAL (readyRead ()),0,0);
73 QObject::connect (a, SIGNAL (readyRead ()), a,
74 SLOT (incomingData ()));
78 void
79 Callbacks::closeSocket (void *s)
81 WlmSocket *a = (WlmSocket*)s;
82 if (a)
84 a->close ();
85 socketList.removeAll (a);
89 void
90 Callbacks::unregisterSocket (void *s)
92 WlmSocket *a = (WlmSocket*)s;
93 if (a)
95 QObject::disconnect(a, SIGNAL (readyRead ()),0,0);
99 void
100 Callbacks::gotFriendlyName (MSN::NotificationServerConnection * conn,
101 std::string friendlyname)
103 Q_UNUSED( conn );
104 myFriendlyName = friendlyname.c_str ();
105 emit gotDisplayName (friendlyname.c_str ());
108 void
109 Callbacks::fileTransferInviteResponse (MSN::SwitchboardServerConnection * conn,
110 unsigned int sessionID, bool response)
112 emit slotfileTransferInviteResponse (conn, sessionID, response);
115 void
116 Callbacks::gotContactDisplayPicture (MSN::SwitchboardServerConnection * conn,
117 MSN::Passport passport,
118 std::string filename)
120 Q_UNUSED( conn );
121 emit gotDisplayPicture (passport.c_str (), filename.c_str ());
124 void
125 Callbacks::gotMessageSentACK (MSN::SwitchboardServerConnection * conn,
126 int trID)
128 emit messageSentACK (conn, trID);
131 void
132 Callbacks::gotBuddyListInfo (MSN::NotificationServerConnection * conn,
133 MSN::ListSyncInfo * info)
135 // IMPORTANT
136 // Here you need to fill a vector with all your contacts
137 // both received by the server and previous ones.
138 // Next pass this vector to the function completeConnection()
139 // if you dont call completeConnection(), the service will
140 // not work.
141 std::map < std::string, MSN::Buddy * >::iterator i =
142 info->contactList.begin ();
143 std::map < std::string, int >allContacts;
145 for (; i != info->contactList.end (); ++i)
147 MSN::Buddy * contact = (*i).second;
148 if (contact->lists & MSN::LST_AB) // only if it is the address book
150 allContacts[contact->userName.c_str ()] = 0;
151 allContacts[contact->userName.c_str ()] |= MSN::LST_AB;
152 std::list < MSN::Buddy::PhoneNumber >::iterator pns =
153 contact->phoneNumbers.begin ();
154 std::list < MSN::Group * >::iterator g = contact->groups.begin ();
156 if (contact->lists & MSN::LST_AL)
158 allContacts[contact->userName.c_str ()] |= MSN::LST_AL;
161 if (contact->lists & MSN::LST_BL)
163 allContacts[contact->userName.c_str ()] |= MSN::LST_BL;
166 if (contact->lists & MSN::LST_RL)
168 //printf ("-RL %s \n", contact->userName.c_str ());
170 if (contact->lists & MSN::LST_PL)
172 //printf ("-PL %s \n", contact->userName.c_str ());
175 //printf ("Available Groups:\n");
176 std::map < std::string, MSN::Group >::iterator g = info->groups.begin ();
178 for (; g != info->groups.end (); g++)
180 //printf (" %s: %s\n", (*g).second.groupID.c_str (),
181 // (*g).second.name.c_str ());
184 // this will send the ADL command to the server
185 // It is necessary. Dont forget to add *all* your contacts to allContacts,
186 // (both Forward, allow and block lists) or you probably will
187 // loose someone.
188 // A contact cannot be present both on allow and block lists or the
189 // server will return an error, so you need to let your application
190 // choose the better list to put it in.
191 m_server->m_account->groupListReceivedFromServer (info->groups);
192 m_server->m_account->addressBookReceivedFromServer (info->contactList);
193 conn->completeConnection (allContacts, info);
196 void
197 Callbacks::gotLatestListSerial (MSN::NotificationServerConnection * conn,
198 std::string lastChange)
200 Q_UNUSED( conn );
201 Q_UNUSED( lastChange );
204 void
205 Callbacks::gotGTC (MSN::NotificationServerConnection * conn, char c)
207 Q_UNUSED( conn );
208 Q_UNUSED( c );
211 void
212 Callbacks::gotOIMDeleteConfirmation (MSN::NotificationServerConnection * conn,
213 bool success, std::string id)
215 Q_UNUSED( conn );
217 if (success)
219 emit deletedOIM (id.c_str (), success);
220 std::cout << "OIM " << id << " removed sucessfully." << std::endl;
222 else
223 std::cout << "OIM " << id << " not removed sucessfully." << std::endl;
227 void
228 Callbacks::gotOIMSendConfirmation (MSN::NotificationServerConnection * conn,
229 bool success, int id)
231 Q_UNUSED( conn );
233 if (success)
234 std::cout << "OIM " << id << " sent sucessfully." << std::endl;
235 else
236 std::cout << "OIM " << id << " not sent sucessfully." << std::endl;
239 void
240 Callbacks::gotOIM (MSN::NotificationServerConnection * conn, bool success,
241 std::string id, std::string message)
243 Q_UNUSED( conn );
245 if (success)
246 emit receivedOIM (id.c_str (), message.c_str ());
247 else
248 std::cout << "Error retreiving OIM " << id << std::endl;
251 void
252 Callbacks::gotOIMList (MSN::NotificationServerConnection * conn,
253 std::vector < MSN::eachOIM > OIMs)
255 Q_UNUSED( conn );
256 emit receivedOIMList (OIMs);
259 void
260 Callbacks::connectionReady (MSN::Connection * conn)
262 Q_UNUSED( conn );
263 emit connectionCompleted ();
266 void
267 Callbacks::gotBLP (MSN::NotificationServerConnection * conn, char c)
269 Q_UNUSED( conn );
270 Q_UNUSED( c );
273 void
274 Callbacks::addedListEntry (MSN::NotificationServerConnection * conn,
275 MSN::ContactList list, MSN::Passport username,
276 std::string friendlyname)
278 Q_UNUSED( conn );
279 QString username1 (username.c_str ());
280 QString friendlyname1 (friendlyname.c_str ());
282 emit gotNewContact (list, username1, friendlyname1);
283 // after adding the user you need to delete it from the pending list.
284 // it will be added automatically by the msn service
286 // on regular lists you'll never receive the contacts displayname
287 // it is not needed anyway
290 void
291 Callbacks::removedListEntry (MSN::NotificationServerConnection * conn,
292 MSN::ContactList list, MSN::Passport username)
294 Q_UNUSED( conn );
295 emit gotRemovedContactFromList (list, username.c_str ());
298 void
299 Callbacks::addedGroup (MSN::NotificationServerConnection * conn, bool added,
300 std::string groupName, std::string groupID)
302 Q_UNUSED( conn );
303 /* if (added)
304 printf ("A group named %s (%s) was added\n", groupName.c_str (),
305 groupID.c_str ());
306 else
307 printf ("Group (%s) was NOT added\n", groupName.c_str ());
309 emit gotAddedGroup (added, QString(groupName.c_str()),
310 QString(groupID.c_str()));
313 void
314 Callbacks::removedGroup (MSN::NotificationServerConnection * conn,
315 bool removed, std::string groupID)
317 Q_UNUSED( conn );
319 if (removed)
320 printf ("A group with ID %s was removed\n", groupID.c_str ());
321 else
322 printf ("Group (%s) was NOT removed\n", groupID.c_str ());
324 emit gotRemovedGroup (removed, QString(groupID.c_str()));
327 void
328 Callbacks::renamedGroup (MSN::NotificationServerConnection * conn,
329 bool renamed, std::string newGroupName,
330 std::string groupID)
332 Q_UNUSED( conn );
333 Q_UNUSED( renamed );
334 Q_UNUSED( newGroupName );
335 Q_UNUSED( groupID );
337 if (renamed)
338 printf ("A group with ID %s was renamed to %s\n", groupID.c_str (),
339 newGroupName.c_str ());
340 else
341 printf ("A group with ID %s was NOT renamed to %s\n",
342 groupID.c_str (), newGroupName.c_str ());
346 void
347 Callbacks::showError (MSN::Connection * conn, std::string msg)
349 Q_UNUSED( conn );
350 std::cout << "MSN: Error: " << msg.c_str () << std::endl;
351 QString a = msg.c_str ();
352 // FIXME
353 if (a.contains ("Wrong Password"))
355 emit wrongPassword ();
359 void
360 Callbacks::buddyChangedStatus (MSN::NotificationServerConnection * conn,
361 MSN::Passport buddy, std::string friendlyname,
362 MSN::BuddyStatus status, unsigned int clientID,
363 std::string msnobject)
365 Q_UNUSED( conn );
366 emit contactChangedStatus (buddy, QString(friendlyname.c_str()), status, clientID,
367 QString(msnobject.c_str()));
370 void
371 Callbacks::buddyOffline (MSN::NotificationServerConnection * conn,
372 MSN::Passport buddy)
374 Q_UNUSED( conn );
375 emit contactDisconnected (buddy);
378 void
379 Callbacks::gotSwitchboard (MSN::SwitchboardServerConnection * conn,
380 const void *tag)
382 emit gotNewSwitchboard (dynamic_cast <
383 MSN::SwitchboardServerConnection * >(conn), tag);
386 void
387 Callbacks::buddyJoinedConversation (MSN::SwitchboardServerConnection * conn,
388 MSN::Passport username,
389 std::string friendlyname, int is_initial)
391 Q_UNUSED( is_initial );
393 QString a (username.c_str ());
394 QString b (friendlyname.c_str ());
395 emit joinedConversation (conn, a, b);
396 const std::pair < std::string,
397 std::string > *ctx = static_cast < const std::pair < std::string,
398 std::string > *>(conn->auth.tag);
399 if (ctx)
400 delete ctx;
401 conn->auth.tag = NULL;
403 /* if (conn->auth.tag)
405 const std::pair<std::string, std::string> *ctx = static_cast<const std::pair<std::string, std::string> *>(conn->auth.tag);
406 // Example of sending a custom emoticon
407 // conn->myNotificationServer()->msnobj.addMSNObject("/tmp/emoticon.gif",2);
408 // std::string obj;
409 // conn->myNotificationServer()->msnobj.getMSNObjectXML("/tmp/emoticon.gif", 2, obj);
410 // conn->sendEmoticon("(EMOTICON)", obj);
412 conn->sendMessage(ctx->second);
413 delete ctx;
414 conn->auth.tag = NULL;
416 //Example of sending a file
417 // MSN::fileTransferInvite ft;
418 // ft.filename = "/tmp/filetosend.txt";
419 // ft.friendlyname = "filetosend2.txt";
420 // ft.sessionId = sessionID++;
421 // ft.type = MSN::FILE_TRANSFER_WITHOUT_PREVIEW;
422 // conn->sendFile(ft);
424 // conn->sendNudge();
425 // conn->sendAction("Action message here");
427 // Exemple of requesting a display picture.
428 // std::string filename2("/tmp/displayPicture.bin"+MSN::toStr(sessionID));
429 // lastObject is the msnobject received on each contact status change
430 // you should generate a random sessionID
431 // conn->requestFile(sessionID++, filename2, lastObject);
433 // Example of sending a voice clip
434 // conn->myNotificationServer()->msnobj.addMSNObject("/tmp/voiceclip.wav",11);
435 // std::string obj;
436 // conn->myNotificationServer()->msnobj.getMSNObjectXML("/tmp/voiceclip.wav", 11, obj);
437 // conn->sendVoiceClip(obj);
438 // exemple of sending an ink
439 // std::string ink("base64 data here...");
440 // conn->sendInk(ink);
445 void
446 Callbacks::buddyLeftConversation (MSN::SwitchboardServerConnection * conn,
447 MSN::Passport username)
449 QString a (username.c_str ());
450 emit leftConversation (conn, a);
454 void
455 Callbacks::gotInstantMessage (MSN::SwitchboardServerConnection * conn,
456 MSN::Passport username,
457 std::string friendlyname, MSN::Message * msg)
459 Q_UNUSED( friendlyname );
461 QString a = username.c_str ();
462 Kopete::Message kmsg;
463 kmsg.setPlainBody (msg->getBody ().c_str ());
464 QFont font (msg->getFontName ().c_str ());
465 if (msg->getFontEffects () & MSN::Message::BOLD_FONT)
466 font.setBold (true);
467 if (msg->getFontEffects () & MSN::Message::ITALIC_FONT)
468 font.setItalic (true);
469 if (msg->getFontEffects () & MSN::Message::UNDERLINE_FONT)
470 font.setUnderline (true);
471 if (msg->getFontEffects () & MSN::Message::STRIKETHROUGH_FONT)
472 font.setStrikeOut (true);
474 QColor color (msg->getColor ()[0], msg->getColor ()[1],
475 msg->getColor ()[2]);
476 kmsg.setForegroundColor (color);
478 kmsg.setFont (font);
479 emit messageReceived (conn, a, kmsg);
482 void
483 Callbacks::gotEmoticonNotification (MSN::SwitchboardServerConnection * conn,
484 MSN::Passport username, std::string alias,
485 std::string msnobject)
487 emit slotGotEmoticonNotification(conn, username, QString(alias.c_str()), QString(msnobject.c_str()));
490 void
491 Callbacks::failedSendingMessage (MSN::Connection * conn)
493 Q_UNUSED( conn );
494 //printf ("**************************************************\n");
495 //printf ("ERROR: Your last message failed to send correctly\n");
496 //printf ("**************************************************\n");
499 void
500 Callbacks::buddyTyping (MSN::SwitchboardServerConnection * conn,
501 MSN::Passport username, std::string friendlyname)
503 Q_UNUSED( friendlyname );
504 QString userid (username.c_str ());
505 emit receivedTypingNotification (conn, userid);
509 void
510 Callbacks::gotNudge (MSN::SwitchboardServerConnection * conn,
511 MSN::Passport username)
513 emit receivedNudge (conn, username.c_str ());
516 void
517 Callbacks::gotVoiceClipNotification (MSN::SwitchboardServerConnection * conn,
518 MSN::Passport username, std::string msnobject)
520 emit slotGotVoiceClipNotification(conn, username, QString(msnobject.c_str()));
523 void
524 Callbacks::gotWinkNotification (MSN::SwitchboardServerConnection * conn,
525 MSN::Passport username, std::string msnobject)
527 emit slotGotWinkNotification(conn, username, QString(msnobject.c_str()));
530 void
531 Callbacks::gotInk (MSN::SwitchboardServerConnection * conn,
532 MSN::Passport username, std::string image)
534 emit slotGotInk(conn, username, QString(image.c_str()));
537 void
538 Callbacks::gotActionMessage (MSN::SwitchboardServerConnection * conn,
539 MSN::Passport username, std::string message)
541 Q_UNUSED( conn );
542 Q_UNUSED( username );
543 Q_UNUSED( message );
546 void
547 Callbacks::gotInitialEmailNotification (MSN::NotificationServerConnection *
548 conn, int msgs_inbox,
549 int unread_inbox, int msgs_folders,
550 int unread_folders)
552 Q_UNUSED( conn );
553 Q_UNUSED( msgs_inbox );
554 Q_UNUSED( unread_inbox );
555 Q_UNUSED( msgs_folders );
556 Q_UNUSED( unread_folders );
558 if (unread_inbox > 0)
559 printf ("You have %d new messages in your Inbox. Total: %d\n",
560 unread_inbox, msgs_inbox);
562 if (unread_folders > 0)
563 printf ("You have %d new messages in other folders. Total: %d\n",
564 unread_folders, msgs_folders);
568 void
569 Callbacks::gotNewEmailNotification (MSN::NotificationServerConnection * conn,
570 std::string from, std::string subject)
572 Q_UNUSED( conn );
573 Q_UNUSED( from );
574 Q_UNUSED( subject );
575 // printf ("New e-mail has arrived from %s.\nSubject: %s\n", from.c_str (),
576 // subject.c_str ());
579 void
580 Callbacks::fileTransferProgress (MSN::SwitchboardServerConnection * conn,
581 unsigned int sessionID,
582 unsigned long long transferred,
583 unsigned long long total)
585 Q_UNUSED( total );
586 emit gotFileTransferProgress (conn, sessionID, transferred);
589 void
590 Callbacks::fileTransferFailed (MSN::SwitchboardServerConnection * conn,
591 unsigned int sessionID, MSN::fileTransferError error)
593 emit gotFileTransferFailed (conn, sessionID, error);
596 void
597 Callbacks::fileTransferSucceeded (MSN::SwitchboardServerConnection * conn,
598 unsigned int sessionID)
600 //printf ("File transfer successfully completed. session: %d\n", sessionID);
601 emit gotFileTransferSucceeded (conn, sessionID);
604 void
605 Callbacks::gotNewConnection (MSN::Connection * conn)
607 if (dynamic_cast < MSN::NotificationServerConnection * >(conn))
608 dynamic_cast <MSN::NotificationServerConnection *>(conn)->synchronizeContactList ();
611 void
612 Callbacks::buddyChangedPersonalInfo (MSN::NotificationServerConnection * conn,
613 MSN::Passport fromPassport,
614 MSN::personalInfo pInfo)
616 Q_UNUSED( conn );
617 // MSN::personalInfo shows all the data you can grab from the contact
618 //printf ("User %s Personal Message: %s\n", fromPassport.c_str (),
619 // pInfo.PSM.c_str ());
620 emit gotContactPersonalInfo (fromPassport, pInfo);
623 void
624 Callbacks::closingConnection (MSN::Connection * conn)
626 if (dynamic_cast < MSN::SwitchboardServerConnection * >(conn))
627 emit SwitchboardServerConnectionTerminated (
628 dynamic_cast <MSN::SwitchboardServerConnection* >(conn));
629 if (dynamic_cast < MSN::NotificationServerConnection * >(conn))
630 emit NotificationServerConnectionTerminated (
631 dynamic_cast <MSN::NotificationServerConnection* >(conn));
634 void
635 Callbacks::changedStatus (MSN::NotificationServerConnection * conn,
636 MSN::BuddyStatus state)
638 Q_UNUSED( conn );
639 //printf ("Your state is now: %s\n",
640 // MSN::buddyStatusToString (state).c_str ());
641 emit changedStatus (state);
642 /* MSN::personalInfo pInfo;
643 pInfo.PSM="my personal message";
644 pInfo.mediaType="Music";
645 pInfo.mediaIsEnabled=1;
646 pInfo.mediaFormat="{0} - {1}";
647 pInfo.mediaLines.push_back("Artist");
648 pInfo.mediaLines.push_back("Song");
649 conn->setPersonalStatus(pInfo);
653 size_t
654 Callbacks::getDataFromSocket (void *sock, char *data, size_t size)
656 WlmSocket *a = (WlmSocket*)sock;
657 if (!a)
658 return 0;
660 return a->read(data, size);
663 size_t
664 Callbacks::writeDataToSocket (void *sock, char *data, size_t size)
666 WlmSocket *a = (WlmSocket*)sock;
667 if (!a)
668 return 0;
670 return a->write(data, size);
673 void *
674 Callbacks::connectToServer (std::string hostname, int port, bool * connected, bool isSSL)
676 WlmSocket *a = new WlmSocket (mainConnection, isSSL);
677 if(!a)
678 return NULL;
680 connect( a, SIGNAL( sslErrors(const QList<QSslError> &) ), a, SLOT(
681 ignoreSslErrors() ) );
683 if(!isSSL)
684 a->connectToHost (hostname.c_str (), port);
685 else
686 a->connectToHostEncrypted (hostname.c_str (), port);
688 *connected = false;
689 socketList.append (a);
690 return (void*)a;
694 Callbacks::listenOnPort (int port)
696 Q_UNUSED( port );
697 // this callback is not used yet,
698 // so, for now we are returning a dummy
699 // value to avoid compiling issues
700 return 0;
703 std::string Callbacks::getOurIP (void)
705 // this callback is not used yet,
706 // so, for now we are returning a dummy
707 // value to avoid compiling issues
708 return "";
711 void
712 Callbacks::log (int i, const char *s)
714 Q_UNUSED( i );
715 Q_UNUSED( s );
719 Callbacks::getSocketFileDescriptor (void *sock)
721 WlmSocket *a = (WlmSocket*)sock;
722 if(!a)
723 return -1;
724 return a->socketDescriptor();
727 std::string Callbacks::getSecureHTTPProxy ()
729 return "";
732 void
733 Callbacks::askFileTransfer (MSN::SwitchboardServerConnection * conn,
734 MSN::fileTransferInvite ft)
736 emit incomingFileTransfer (conn, ft);
738 switch(ft.type)
740 case MSN::FILE_TRANSFER_BACKGROUND_SHARING:
741 printf("User %s wants to share with you a background file named %s. Size: %llu. Accepting..\n", ft.userPassport.c_str(), ft.filename.c_str(), ft.filesize);
742 break;
743 case MSN::FILE_TRANSFER_BACKGROUND_SHARING_CUSTOM:
744 printf("User %s wants to share with you a *custom background file named %s. Size: %llu. Accepting..\n", ft.userPassport.c_str(), ft.filename.c_str(), ft.filesize);
745 break;
746 case MSN::FILE_TRANSFER_WITH_PREVIEW:
747 printf("User %s wants to send you a file *with preview named %s. Size: %llu. Accepting..\n", ft.userPassport.c_str(), ft.filename.c_str(), ft.filesize);
748 // ft.preview has the base64 encoded png file
749 break;
750 case MSN::FILE_TRANSFER_WITHOUT_PREVIEW:
751 printf("User %s wants to send you a file *without preview named %s. Size: %llu. Accepting..\n", ft.userPassport.c_str(), ft.filename.c_str(), ft.filesize);
752 break;
753 default:
754 printf("Unknown filetransfer type from %s..\n", ft.userPassport.c_str());
757 conn->fileTransferResponse(ft.sessionId, filename2, true);
761 void
762 Callbacks::addedContactToGroup (MSN::NotificationServerConnection * conn,
763 bool added, std::string groupId,
764 std::string contactId)
766 Q_UNUSED( conn );
768 if (added)
769 printf ("User Id (%s) added to group Id (%s)\n", contactId.c_str (),
770 groupId.c_str ());
771 else
772 printf ("User Id (%s) NOT added to group Id (%s)\n",
773 contactId.c_str (), groupId.c_str ());
775 emit gotAddedContactToGroup (added, QString(groupId.c_str()),
776 QString(contactId.c_str()));
779 void
780 Callbacks::removedContactFromGroup (MSN::NotificationServerConnection * conn,
781 bool removed, std::string groupId,
782 std::string contactId)
784 Q_UNUSED( conn );
786 if (removed)
787 printf ("User Id (%s) removed from group Id (%s)\n",
788 contactId.c_str (), groupId.c_str ());
789 else
790 printf ("User Id (%s) NOT removed from group Id (%s)\n",
791 contactId.c_str (), groupId.c_str ());
793 emit gotRemovedContactFromGroup (removed, QString(groupId.c_str()),
794 QString(contactId.c_str()));
797 void
798 Callbacks::addedContactToAddressBook (MSN::NotificationServerConnection *
799 conn, bool added, std::string passport,
800 std::string displayName,
801 std::string guid)
803 Q_UNUSED( conn );
805 if (added)
806 printf ("User (%s - %s) added to AddressBook. Guid (%s)\n",
807 passport.c_str (), displayName.c_str (), guid.c_str ());
808 else
809 printf ("User (%s - %s) NOT added to AddressBook.\n",
810 passport.c_str (), displayName.c_str ());
812 emit gotAddedContactToAddressBook (added, QString(passport.c_str()),
813 QString(displayName.c_str()), QString(guid.c_str()));
816 void
817 Callbacks::removedContactFromAddressBook (MSN::NotificationServerConnection *
818 conn, bool removed,
819 std::string contactId,
820 std::string passport)
822 Q_UNUSED( conn );
824 if (removed)
825 printf ("User %s removed from AddressBook. Guid (%s)\n",
826 passport.c_str (), contactId.c_str ());
827 else
828 printf ("User %s NOT removed from AddressBook. Guid (%s)\n",
829 passport.c_str (), contactId.c_str ());
831 emit gotRemovedContactFromAddressBook (removed, QString(passport.c_str()),
832 QString(contactId.c_str()));
835 void
836 Callbacks::enabledContactOnAddressBook (MSN::NotificationServerConnection *
837 conn, bool enabled,
838 std::string contactId,
839 std::string passport)
841 Q_UNUSED( conn );
842 Q_UNUSED( enabled );
843 Q_UNUSED( contactId );
844 Q_UNUSED( passport );
846 // this is used to enable a contact previously disabled from msn, but not fully removed
847 if (enabled)
848 printf ("User (%s) enabled on AddressBook. Guid (%s)\n",
849 passport.c_str (), contactId.c_str ());
850 else
851 printf ("User (%s) NOT enabled on AddressBook. Guid (%s)\n",
852 passport.c_str (), contactId.c_str ());
856 void
857 Callbacks::disabledContactOnAddressBook (MSN::NotificationServerConnection *
858 conn, bool disabled,
859 std::string contactId)
861 Q_UNUSED( conn );
862 Q_UNUSED( disabled );
863 Q_UNUSED( contactId );
864 // this is used when you have disabled this user from msn, but not deleted from hotmail
865 // I suggest to delete the contact instead of disable, since I haven't tested this too much yet
867 if (disabled)
868 printf ("User disabled on AddressBook. Guid (%s)\n",
869 contactId.c_str ());
870 else
871 printf ("User NOT disabled on AddressBook. Guid (%s)\n",
872 contactId.c_str ());
876 void Callbacks::gotVoiceClipFile(MSN::SwitchboardServerConnection * conn, unsigned int sessionID, std::string file)
878 emit slotGotVoiceClipFile(conn, sessionID, QString(file.c_str()));
881 void Callbacks::gotEmoticonFile(MSN::SwitchboardServerConnection * conn, unsigned int sessionID, std::string alias, std::string file)
883 emit slotGotEmoticonFile(conn, sessionID, QString(alias.c_str()), QString(file.c_str()));
886 void Callbacks::gotWinkFile(MSN::SwitchboardServerConnection * conn, unsigned int sessionID, std::string file)
888 emit slotGotWinkFile(conn, sessionID, QString(file.c_str()));
891 #include "wlmlibmsn.moc"