• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdenetwork
  • Sitemap
  • Contact Us
 

kopete/protocols/messenger/libpapillon

contactlist.cpp

Go to the documentation of this file.
00001 /*
00002    contactlist.cpp - Windows Live Messenger Contact List
00003 
00004    Copyright (c) 2006 by Michaƫl Larouche <larouche@kde.org>
00005 
00006    *************************************************************************
00007    *                                                                       *
00008    * This library is free software; you can redistribute it and/or         *
00009    * modify it under the terms of the GNU Lesser General Public            *
00010    * License as published by the Free Software Foundation; either          *
00011    * version 2 of the License, or (at your option) any later version.      *
00012    *                                                                       *
00013    *************************************************************************
00014  */
00015 #include "Papillon/ContactList"
00016 
00017 // Qt includes
00018 #include <QtCore/QPointer>
00019 
00020 // Papillon includes
00021 #include "Papillon/Client"
00022 #include "Papillon/Contact"
00023 
00024 // Papillon private includes
00025 #include "fetchcontactlistjob.h"
00026 
00027 namespace Papillon 
00028 {
00029 
00030 class ContactList::Private
00031 {
00032 public:
00033     Private()
00034     {}
00035     
00036     ~Private()
00037     {
00038     }
00039 
00040     QPointer<Client> client;
00041     // Contacts are deleted by QObject subclassing
00042     QList<Contact*> contacts;
00043 };
00044 
00045 ContactList::ContactList(Client *client)
00046  : QObject(client), d(new Private)
00047 {
00048     d->client = client;
00049 }
00050 
00051 
00052 ContactList::~ContactList()
00053 {
00054     delete d;
00055 }
00056 
00057 Client *ContactList::client()
00058 {
00059     return d->client;
00060 }
00061 
00062 QList<Papillon::Contact*> ContactList::contacts() const
00063 {
00064     QList<Contact*> result;
00065     
00066     foreach(Contact *contact, d->contacts)
00067     {
00068         if( contact->lists() & ContactListEnums::ForwardList )
00069         {
00070             result << contact;
00071         }
00072     }
00073     return result;
00074 }
00075 
00076 QList<Papillon::Contact*> ContactList::allowList() const
00077 {
00078     QList<Contact*> result;
00079 
00080     foreach(Contact *contact, d->contacts)
00081     {
00082         if( contact->lists() & ContactListEnums::AllowList )
00083         {
00084             result << contact;
00085         }
00086     }
00087 
00088     return result;
00089 }
00090 
00091 QList<Papillon::Contact*> ContactList::blockList() const
00092 {
00093     QList<Contact*> result;
00094     
00095     foreach(Contact *contact, d->contacts)
00096     {
00097         if( contact->lists() & ContactListEnums::BlockList )
00098         {
00099             result << contact;
00100         }
00101     }
00102 
00103     return result;
00104 }
00105 
00106 QList<Papillon::Contact*> ContactList::reverseList() const
00107 {
00108     QList<Contact*> result;
00109 
00110     foreach(Contact *contact, d->contacts)
00111     {
00112         if( contact->lists() & ContactListEnums::ReverseList )
00113         {
00114             result << contact;
00115         }
00116     }
00117 
00118     return result;
00119 }
00120 
00121 QList<Papillon::Contact*> ContactList::pendingList() const
00122 {
00123     QList<Contact*> result;
00124 
00125     foreach(Contact *contact, d->contacts)
00126     {
00127         if( contact->lists() & ContactListEnums::PendingList )
00128         {
00129             result << contact;
00130         }
00131     }
00132 
00133     return result;
00134 }
00135 
00136 Contact* ContactList::contact(const QString &contactId)
00137 {
00138     Contact *foundContact = 0, *contact = 0;
00139     
00140     foreach(contact, d->contacts)
00141     {
00142         if( contact->contactId() == contactId || contact->passportId() == contactId )
00143         {
00144             foundContact = contact;
00145             break;
00146         }
00147     }
00148 
00149     return foundContact;
00150 }
00151 
00152 void ContactList::load()
00153 {
00154     FetchContactListJob *fetchJob = new FetchContactListJob(this);
00155     // FIXME: Temp
00156     connect(fetchJob, SIGNAL(finished(Papillon::FetchContactListJob*)), this, SIGNAL(contactListLoaded()));
00157     fetchJob->execute();
00158 }
00159 
00160 Contact* ContactList::createContact(const QString &contactId)
00161 {
00162     if( !contact(contactId) )
00163     {
00164         Contact *newContact = new Contact(this);
00165         newContact->setContactId(contactId);
00166 
00167         d->contacts << newContact;
00168     }
00169 
00170     return contact(contactId);
00171 }
00172 
00173 }
00174 
00175 #include "contactlist.moc"

kopete/protocols/messenger/libpapillon

Skip menu "kopete/protocols/messenger/libpapillon"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdenetwork

Skip menu "kdenetwork"
  • kget
  • kopete
  •   kopete
  •   libkopete
  •       libpapillon
  • krfb
Generated for kdenetwork by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal