~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to protocols/oscar/oscaraccount.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  oscaraccount.h  -  Oscar Account Class
 
3
 
 
4
    Copyright (c) 2002 by Tom Linsky <twl6@po.cwru.edu>
 
5
    Copyright (c) 2002 by Chris TenHarmsel <tenharmsel@staticmethod.net>
 
6
    Kopete    (c) 2002-2008 by the Kopete developers  <kopete-devel@kde.org>
 
7
 
 
8
    *************************************************************************
 
9
    *                                                                       *
 
10
    * This program is free software; you can redistribute it and/or modify  *
 
11
    * it under the terms of the GNU General Public License as published by  *
 
12
    * the Free Software Foundation; either version 2 of the License, or     *
 
13
    * (at your option) any later version.                                   *
 
14
    *                                                                       *
 
15
    *************************************************************************
 
16
*/
 
17
 
 
18
#ifndef OSCARACCOUNT_H
 
19
#define OSCARACCOUNT_H
 
20
 
 
21
#include <qstring.h>
 
22
#include <qwidget.h>
 
23
 
 
24
#include "kopetepasswordedaccount.h"
 
25
#include "oscartypeclasses.h"
 
26
#include "oscarcontact.h"
 
27
#include "contact.h"
 
28
#include "kopete_export.h"
 
29
 
 
30
class QDomNode;
 
31
 
 
32
namespace Kopete
 
33
{
 
34
class Contact;
 
35
class Group;
 
36
class FileTransferInfo;
 
37
}
 
38
 
 
39
namespace Oscar {
 
40
class Client;
 
41
}
 
42
class ClientStream;
 
43
class OscarContact;
 
44
class OscarAccountPrivate;
 
45
class QTextCodec;
 
46
class OContact;
 
47
 
 
48
class OSCAR_EXPORT OscarAccount : public Kopete::PasswordedAccount
 
49
{
 
50
        Q_OBJECT
 
51
 
 
52
public:
 
53
        OscarAccount(Kopete::Protocol *parent, const QString &accountID, bool isICQ=false);
 
54
        virtual ~OscarAccount();
 
55
 
 
56
        /** Provide the derived accounts and contacts with access to the backend */
 
57
        Oscar::Client* engine();
 
58
 
 
59
        /** Disconnects this account */
 
60
        virtual void disconnect();
 
61
 
 
62
        /**
 
63
         * Handle the various ways we can be logged off the oscar service
 
64
         * and handle the passthrough of the disconnection through the API.
 
65
         */
 
66
        void logOff( Kopete::Account::DisconnectReason );
 
67
 
 
68
        /**
 
69
         * Was the password wrong last time we tried to connect?
 
70
         */
 
71
        bool passwordWasWrong();
 
72
 
 
73
        /**
 
74
         * Fill the menu for this account
 
75
         */
 
76
        virtual void fillActionMenu( KActionMenu *actionMenu ) = 0;
 
77
 
 
78
        /**
 
79
         * Sets the identity this account belongs to
 
80
         */
 
81
        virtual bool setIdentity( Kopete::Identity *ident );
 
82
 
 
83
        /** Set the server address */
 
84
        void setServerAddress( const QString& server );
 
85
 
 
86
        /** Set the server port */
 
87
        void setServerPort( int port );
 
88
 
 
89
        /** Set the server encryption */
 
90
        void setServerEncrypted( bool encrypted );
 
91
 
 
92
    /** Set the proxy server address */
 
93
    void setProxyServerAddress( const QString& server );
 
94
 
 
95
    /** Set the proxy server port */
 
96
    void setProxyServerPort( int port );
 
97
 
 
98
    /** Set the proxy server encryption */
 
99
    void setProxyServerEncrypted( bool encrypted );
 
100
 
 
101
    void setProxyServerEnabled(bool);
 
102
 
 
103
        /** Returns codec for account's default encoding */
 
104
        QTextCodec* defaultCodec() const;
 
105
 
 
106
        /**
 
107
         * Returns codec for given contact's encoding or default one
 
108
         * if contact has no encoding
 
109
         */
 
110
        QTextCodec* contactCodec( const OscarContact* contact ) const;
 
111
 
 
112
        /**
 
113
         * Returns codec for given contact's encoding or default one
 
114
         * if contact has no encoding
 
115
         */
 
116
        QTextCodec* contactCodec( const QString& contactName ) const;
 
117
 
 
118
        /**
 
119
         * Updates buddy icon
 
120
         */
 
121
        void updateBuddyIcon( const QString &path );
 
122
 
 
123
        /**
 
124
         * Add a contact to the server site list
 
125
         * \param contactName the screen name of the new contact to add
 
126
         * \param groupName the group of the new contact
 
127
         * \param autoAddGroup if the group doesn't exist add that group
 
128
         * \return true if the contact will be added
 
129
         */
 
130
        bool addContactToSSI( const QString& contactName, const QString& groupName, bool autoAddGroup );
 
131
 
 
132
        /**
 
133
         * Change a contact's group on the server
 
134
         * \param contact the contact to change
 
135
         * \param newGroup the new group to move the contact to
 
136
         * \param autoAddGroup if the new group doesn't exist add that group
 
137
         * \return true if the contact will be added
 
138
         */
 
139
        bool changeContactGroupInSSI( const QString& contact, const QString& newGroupName, bool autoAddGroup );
 
140
 
 
141
public slots:
 
142
        void slotGoOffline();
 
143
 
 
144
        void slotGoOnline();
 
145
 
 
146
protected:
 
147
        /**
 
148
         * Adds a contact to a meta contact
 
149
         */
 
150
        friend class OscarProtocol;
 
151
        virtual bool createContact(const QString &contactId,
 
152
                 Kopete::MetaContact *parentContact );
 
153
 
 
154
        /**
 
155
         * Protocols using Oscar must implement this to perform the instantiation
 
156
         * of their contact for Kopete.  Called by @ref createContact().
 
157
         * @param contactId theprotocol unique id of the contact
 
158
         * @param parentContact the parent metacontact
 
159
         * @return whether the creation succeeded or not
 
160
         */
 
161
        virtual OscarContact *createNewContact( const QString &contactId, Kopete::MetaContact *parentContact, const OContact& ssiItem ) = 0;
 
162
 
 
163
        void updateVersionUpdaterStamp();
 
164
 
 
165
        virtual QString sanitizedMessage( const QString& message ) const;
 
166
 
 
167
protected slots:
 
168
 
 
169
        //! do stuff on login
 
170
        virtual void loginActions();
 
171
 
 
172
    void processSSIList();
 
173
 
 
174
        void kopeteGroupRemoved( Kopete::Group* g );
 
175
        void kopeteGroupAdded( Kopete::Group* g );
 
176
        void kopeteGroupRenamed( Kopete::Group* g, const QString& oldName );
 
177
 
 
178
        virtual void messageReceived( const Oscar::Message& message );
 
179
 
 
180
        void ssiGroupAdded( const OContact& );
 
181
        void ssiGroupUpdated( const OContact& ) {}
 
182
        void ssiGroupRemoved( const OContact& ) {}
 
183
        void ssiContactAdded( const OContact& );
 
184
        void ssiContactUpdated( const OContact& );
 
185
        void ssiContactRemoved( const OContact& ) {}
 
186
 
 
187
        /* slots for receiving typing notifications, and notify the appropriate OscarContact */
 
188
        void userStartedTyping( const QString & contact );
 
189
        void userStoppedTyping( const QString & contact );
 
190
 
 
191
    void nonServerAddContactDialogClosed();
 
192
 
 
193
        /** incoming filetransfer */
 
194
        void incomingFileTransfer( FileTransferHandler* handler );
 
195
 
 
196
        void fileTransferDestroyed( QObject* handler );
 
197
        void fileTransferCancelled();
 
198
        void fileTransferRefused( const Kopete::FileTransferInfo& info );
 
199
        void fileTransferAccept( Kopete::Transfer* t , const QString& fileName );
 
200
 
 
201
        void chatroomRequest( ChatRoomHandler* handler );
 
202
 
 
203
signals:
 
204
 
 
205
        void accountDisconnected( Kopete::Account::DisconnectReason reason );
 
206
 
 
207
private:
 
208
        QString getFLAPErrorMessage( int code );
 
209
 
 
210
        /** Updates buddy icon item in ssi */
 
211
        void updateBuddyIconInSSI();
 
212
 
 
213
        QString makeWellFormedXML( const QString& message ) const;
 
214
 
 
215
        QString addQuotesAroundAttributes( QString message ) const;
 
216
 
 
217
        QString sanitizedPlainMessage( const QString& message ) const;
 
218
 
 
219
        QList<QDomNode> getElementsByTagNameCI( const QDomNode& node, const QString& tagName ) const;
 
220
 
 
221
private slots:
 
222
        /** Handler from socket errors from a connection */
 
223
        void slotSocketError( int, const QString& );
 
224
 
 
225
        /** Handle task errors from the client */
 
226
        void slotTaskError( const Oscar::SNAC& s, int errCode, bool fatal ) ;
 
227
 
 
228
        /** Sends buddy icon to server */
 
229
        void slotSendBuddyIcon();
 
230
 
 
231
        /** Identity's property changed */
 
232
        void slotIdentityPropertyChanged( Kopete::PropertyContainer *container, const QString &key,
 
233
                                          const QVariant &oldValue, const QVariant &newValue );
 
234
 
 
235
        /**
 
236
         * Setup a ClientStream for engine
 
237
         */
 
238
        void createClientStream( ClientStream **clientStream );
 
239
 
 
240
private:
 
241
        OscarAccountPrivate *d;
 
242
 
 
243
};
 
244
 
 
245
#endif
 
246
 
 
247
//kate: tab-width 4; indent-mode csands;
 
248