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 
00031 namespace Tp
00032 {
00033 
00034 class TELEPATHY_QT4_EXPORT ContactSearchChannel : public Channel
00035 {
00036     Q_OBJECT
00037     Q_DISABLE_COPY(ContactSearchChannel)
00038 
00039 public:
00040     static const Feature FeatureCore;
00041 
00042     class SearchStateChangeDetails
00043     {
00044     public:
00045         SearchStateChangeDetails();
00046         SearchStateChangeDetails(const SearchStateChangeDetails &other);
00047         ~SearchStateChangeDetails();
00048 
00049         bool isValid() const { return mPriv.constData() != 0; }
00050 
00051         SearchStateChangeDetails &operator=(const SearchStateChangeDetails &other);
00052 
00053         bool hasDebugMessage() const { return allDetails().contains(QLatin1String("debug-message")); }
00054         QString debugMessage() const { return qdbus_cast<QString>(allDetails().value(QLatin1String("debug-message"))); }
00055 
00056         QVariantMap allDetails() const;
00057 
00058     private:
00059         friend class ContactSearchChannel;
00060 
00061         SearchStateChangeDetails(const QVariantMap &details);
00062 
00063         struct Private;
00064         friend struct Private;
00065         QSharedDataPointer<Private> mPriv;
00066     };
00067 
00068     typedef QHash<ContactPtr, Contact::InfoFields> SearchResult;
00069 
00070     static ContactSearchChannelPtr create(const ConnectionPtr &connection,
00071             const QString &objectPath, const QVariantMap &immutableProperties);
00072 
00073     virtual ~ContactSearchChannel();
00074 
00075     ChannelContactSearchState searchState() const;
00076     uint limit() const;
00077     QStringList availableSearchKeys() const;
00078     QString server() const;
00079 
00080     PendingOperation *search(const QString &searchKey, const QString &searchTerm);
00081     PendingOperation *search(const ContactSearchMap &searchTerms);
00082     void continueSearch();
00083     void stopSearch();
00084 
00085 Q_SIGNALS:
00086     void searchStateChanged(Tp::ChannelContactSearchState state, const QString &errorName,
00087             const Tp::ContactSearchChannel::SearchStateChangeDetails &details);
00088     void searchResultReceived(const Tp::ContactSearchChannel::SearchResult &result);
00089 
00090 protected:
00091     ContactSearchChannel(const ConnectionPtr &connection, const QString &objectPath,
00092             const QVariantMap &immutableProperties);
00093 
00094 private Q_SLOTS:
00095     void gotProperties(QDBusPendingCallWatcher *watcher);
00096     void gotSearchState(QDBusPendingCallWatcher *watcher);
00097     void onSearchStateChanged(uint state, const QString &error, const QVariantMap &details);
00098     void onSearchResultReceived(const Tp::ContactSearchResultMap &result);
00099     void gotSearchResultContacts(Tp::PendingOperation *op);
00100 
00101 private:
00102     class PendingSearch;
00103 
00104     struct Private;
00105     friend struct Private;
00106     Private *mPriv;
00107 };
00108 
00109 } // Tp
00110 
00111 #endif


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