~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/accounts/twitter/sip/TwitterSip.h

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 
2
 *
 
3
 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 
4
 *   Copyright 2011, Leo Franchi <lfranchi@kde.org>
 
5
 *   Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
 
6
 *
 
7
 *   Tomahawk is free software: you can redistribute it and/or modify
 
8
 *   it under the terms of the GNU General Public License as published by
 
9
 *   the Free Software Foundation, either version 3 of the License, or
 
10
 *   (at your option) any later version.
 
11
 *
 
12
 *   Tomahawk is distributed in the hope that it will be useful,
 
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
15
 *   GNU General Public License for more details.
 
16
 *
 
17
 *   You should have received a copy of the GNU General Public License
 
18
 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
#ifndef TWITTER_H
 
22
#define TWITTER_H
 
23
 
 
24
#include "accounts/AccountDllMacro.h"
 
25
#include "sip/SipPlugin.h"
 
26
#include "accounts/Account.h"
 
27
#include "accounts/twitter/TomahawkOAuthTwitter.h"
 
28
 
 
29
#include <QTweetLib/qtweetuser.h>
 
30
#include <QTweetLib/qtweetnetbase.h>
 
31
#include <QTweetLib/qtweetfriendstimeline.h>
 
32
#include <QTweetLib/qtweetdirectmessages.h>
 
33
#include <QTweetLib/qtweetdirectmessagenew.h>
 
34
#include <QTweetLib/qtweetdirectmessagedestroy.h>
 
35
#include <QTweetLib/qtweetmentions.h>
 
36
#include <QTweetLib/qtweetdmstatus.h>
 
37
 
 
38
#include <QTimer>
 
39
#include <QWeakPointer>
 
40
#include <QSet>
 
41
 
 
42
 
 
43
class ACCOUNTDLLEXPORT TwitterSipPlugin : public SipPlugin
 
44
{
 
45
    Q_OBJECT
 
46
 
 
47
public:
 
48
    TwitterSipPlugin( Tomahawk::Accounts::Account *account );
 
49
 
 
50
    virtual ~TwitterSipPlugin() {}
 
51
 
 
52
    virtual bool isValid() const;
 
53
    virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const;
 
54
    virtual QString inviteString() const;
 
55
 
 
56
signals:
 
57
    void stateChanged( Tomahawk::Accounts::Account::ConnectionState );
 
58
 
 
59
public slots:
 
60
    virtual void connectPlugin();
 
61
    void disconnectPlugin();
 
62
    void configurationChanged();
 
63
 
 
64
    void sendMsg( const QString& peerId, const SipInfo& info )
 
65
    {
 
66
        Q_UNUSED( peerId );
 
67
        Q_UNUSED( info );
 
68
    }
 
69
 
 
70
    void broadcastMsg( const QString &msg )
 
71
    {
 
72
        Q_UNUSED( msg );
 
73
    }
 
74
 
 
75
    void addContact( const QString &peerId, const QString& msg = QString() )
 
76
    {
 
77
        Q_UNUSED( peerId );
 
78
        Q_UNUSED( msg );
 
79
    }
 
80
 
 
81
    void checkSettings();
 
82
 
 
83
private slots:
 
84
    void accountAuthenticated( const QWeakPointer< TomahawkOAuthTwitter > &twitterAuth, const QTweetUser &user );
 
85
    void checkTimerFired();
 
86
    void connectTimerFired();
 
87
    void friendsTimelineStatuses( const QList< QTweetStatus > &statuses );
 
88
    void mentionsStatuses( const QList< QTweetStatus > &statuses );
 
89
    void pollDirectMessages();
 
90
    void directMessages( const QList< QTweetDMStatus > &messages );
 
91
    void directMessagePosted( const QTweetDMStatus &message );
 
92
    void directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message );
 
93
    void directMessageDestroyed( const QTweetDMStatus &message );
 
94
    void registerOffers( const QStringList &peerList );
 
95
    void registerOffer( const QString &screenName, const QVariantHash &peerdata );
 
96
    void sendOffer( const QString &screenName, const QVariantHash &peerdata );
 
97
    void makeConnection( const QString &screenName, const QVariantHash &peerdata );
 
98
    void fetchAvatar( const QString &screenName );
 
99
    void avatarUserDataSlot( const QTweetUser &user );
 
100
    void profilePicReply();
 
101
 
 
102
private:
 
103
    void syncConfig();
 
104
    bool refreshTwitterAuth();
 
105
    void parseGotTomahawk( const QRegExp &regex, const QString &screenName, const QString &text );
 
106
 
 
107
    QWeakPointer< TomahawkOAuthTwitter > m_cachedTwitterAuth;
 
108
 
 
109
    QWeakPointer< QTweetFriendsTimeline > m_friendsTimeline;
 
110
    QWeakPointer< QTweetMentions > m_mentions;
 
111
    QWeakPointer< QTweetDirectMessages > m_directMessages;
 
112
    QWeakPointer< QTweetDirectMessageNew > m_directMessageNew;
 
113
    QWeakPointer< QTweetDirectMessageDestroy > m_directMessageDestroy;
 
114
 
 
115
    QVariantHash m_configuration;
 
116
 
 
117
    QTimer m_checkTimer;
 
118
    QTimer m_connectTimer;
 
119
    QTimer m_dmPollTimer;
 
120
    qint64 m_cachedFriendsSinceId;
 
121
    qint64 m_cachedMentionsSinceId;
 
122
    qint64 m_cachedDirectMessagesSinceId;
 
123
    QVariantHash m_cachedPeers;
 
124
    QHash< QString, QPixmap > m_cachedAvatars;
 
125
    QSet<QString> m_keyCache;
 
126
    Tomahawk::Accounts::Account::ConnectionState m_state;
 
127
};
 
128
 
 
129
#endif