Home · All Classes · All Namespaces · Modules · Functions · Files

contact-search-channel.h

00001 /*
00002  * This file is part of TelepathyQt4
00003  *
00004  * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
00005  * Copyright (C) 2010 Nokia Corporation
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef _TelepathyQt4_contact_search_channel_h_HEADER_GUARD_
00023 #define _TelepathyQt4_contact_search_channel_h_HEADER_GUARD_
00024 
00025 #ifndef IN_TELEPATHY_QT4_HEADER
00026 #error IN_TELEPATHY_QT4_HEADER
00027 #endif
00028 
00029 #include <TelepathyQt4/Channel>
00030 #include <TelepathyQt4/Contact>
00031 #include <TelepathyQt4/Types>
00032 
00033 namespace Tp
00034 {
00035 
00036 class TELEPATHY_QT4_EXPORT ContactSearchChannel : public Channel
00037 {
00038     Q_OBJECT
00039     Q_DISABLE_COPY(ContactSearchChannel)
00040 
00041 public:
00042     static const Feature FeatureCore;
00043 
00044     class SearchStateChangeDetails
00045     {
00046     public:
00047         SearchStateChangeDetails();
00048         SearchStateChangeDetails(const SearchStateChangeDetails &other);
00049         ~SearchStateChangeDetails();
00050 
00051         bool isValid() const { return mPriv.constData() != 0; }
00052 
00053         SearchStateChangeDetails &operator=(const SearchStateChangeDetails &other);
00054 
00055         bool hasDebugMessage() const { return allDetails().contains(QLatin1String("debug-message")); }
00056         QString debugMessage() const { return qdbus_cast<QString>(allDetails().value(QLatin1String("debug-message"))); }
00057 
00058         QVariantMap allDetails() const;
00059 
00060     private:
00061         friend class ContactSearchChannel;
00062 
00063         SearchStateChangeDetails(const QVariantMap &details);
00064 
00065         struct Private;
00066         friend struct Private;
00067         QSharedDataPointer<Private> mPriv;
00068     };
00069 
00070     typedef QHash<ContactPtr, Contact::InfoFields> SearchResult;
00071 
00072     static ContactSearchChannelPtr create(const ConnectionPtr &connection,
00073             const QString &objectPath, const QVariantMap &immutableProperties);
00074 
00075     virtual ~ContactSearchChannel();
00076 
00077     ChannelContactSearchState searchState() const;
00078     uint limit() const;
00079     QStringList availableSearchKeys() const;
00080     QString server() const;
00081 
00082     PendingOperation *search(const QString &searchKey, const QString &searchTerm);
00083     PendingOperation *search(const ContactSearchMap &searchTerms);
00084     void continueSearch();
00085     void stopSearch();
00086 
00087 Q_SIGNALS:
00088     void searchStateChanged(Tp::ChannelContactSearchState state, const QString &errorName,
00089             const Tp::ContactSearchChannel::SearchStateChangeDetails &details);
00090     void searchResultReceived(const Tp::ContactSearchChannel::SearchResult &result);
00091 
00092 protected:
00093     ContactSearchChannel(const ConnectionPtr &connection, const QString &objectPath,
00094             const QVariantMap &immutableProperties, const Feature &coreFeature);
00095 
00096 private Q_SLOTS:
00097     void gotProperties(QDBusPendingCallWatcher *watcher);
00098     void gotSearchState(QDBusPendingCallWatcher *watcher);
00099     void onSearchStateChanged(uint state, const QString &error, const QVariantMap &details);
00100     void onSearchResultReceived(const Tp::ContactSearchResultMap &result);
00101     void gotSearchResultContacts(Tp::PendingOperation *op);
00102 
00103 private:
00104     class PendingSearch;
00105 
00106     struct Private;
00107     friend struct Private;
00108     Private *mPriv;
00109 };
00110 
00111 } // Tp
00112 
00113 #endif


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.5.6.1