1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
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>
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.
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.
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/>.
24
#include "accounts/AccountDllMacro.h"
25
#include "sip/SipPlugin.h"
26
#include "accounts/Account.h"
27
#include "accounts/twitter/TomahawkOAuthTwitter.h"
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>
39
#include <QWeakPointer>
43
class ACCOUNTDLLEXPORT TwitterSipPlugin : public SipPlugin
48
TwitterSipPlugin( Tomahawk::Accounts::Account *account );
50
virtual ~TwitterSipPlugin() {}
52
virtual bool isValid() const;
53
virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const;
54
virtual QString inviteString() const;
57
void stateChanged( Tomahawk::Accounts::Account::ConnectionState );
60
virtual void connectPlugin();
61
void disconnectPlugin();
62
void configurationChanged();
64
void sendMsg( const QString& peerId, const SipInfo& info )
70
void broadcastMsg( const QString &msg )
75
void addContact( const QString &peerId, const QString& msg = QString() )
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();
104
bool refreshTwitterAuth();
105
void parseGotTomahawk( const QRegExp ®ex, const QString &screenName, const QString &text );
107
QWeakPointer< TomahawkOAuthTwitter > m_cachedTwitterAuth;
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;
115
QVariantHash m_configuration;
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;