summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/meanwhile/meanwhileaccount.h
blob: ba5eafc1834aea0e57805d59b501c11c83e04a1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
    meanwhileaccount.h - meanwhile account

    Copyright (c) 2003-2004 by Sivaram Gottimukkala  <[email protected]>
    Copyright (c) 2005      by Jeremy Kerr <[email protected]>

    Kopete    (c) 2002-2004 by the Kopete developers <[email protected]>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/
#ifndef MEANWHILEACCOUNT_H
#define MEANWHILEACCOUNT_H

#include <kopetepasswordedaccount.h>
#include "meanwhileprotocol.h"
#include "meanwhileplugin.h"

class MeanwhileSession;

/**
 * A class to handle a single Meanwhile Account.
 */
class MeanwhileAccount : public Kopete::PasswordedAccount
{
    TQ_OBJECT
  
public:
    /**
     * Create a new Meanwhile account
     * @param protocol  The MeanwhileProtocol that this acccount is for
     * @param accountID The (meanwhile) account id of this account
     * @param name      The name of this account
     */
    MeanwhileAccount(MeanwhileProtocol *protocol, const TQString &accountID,
            const char *name = 0L);

    ~MeanwhileAccount();

    virtual bool createContact(const TQString &contactId,
                        Kopete::MetaContact *parentContact);

    virtual void connectWithPassword(const TQString &password);

    virtual void disconnect();

    virtual void disconnect(Kopete::Account::DisconnectReason reason);

    virtual TDEActionMenu *actionMenu();

    /** Get the server host name */
    TQString getServerName();
    /** Get the server port */
    int     getServerPort();
    /** Set the server host name */
    void    setServerName(const TQString &server);
    /** Set the server port */
    void    setServerPort(int port);
    /** Provide an information plugin for this account */
    void    setPlugin(MeanwhilePlugin *plugin);

    /** Set the client identification parameters for the sametime connection */
    void    setClientID(int client, int major, int minor);

    /* returns true if custom IDs are in use, and populates the args */
    bool    getClientIDParams(int *clientID, int *verMajor, int *verMinor);

    /** Reset client identification parameters to their defaults */
    void    resetClientID();

    MeanwhilePlugin *infoPlugin;

    /**
     * Save the current contact list to the server
     */
    void syncContactsToServer();

    /**
     * Get a reference to the meanwhile session object, if one exists
     */
    MeanwhileSession *session();

    /**
     * Get the meanwhile id for this account
     * @return The meanwhile ID for the account
     */
    TQString meanwhileId() const;

public slots:
    /**
     * Called by the session to notify that the state has changed
     */
    void slotSessionStateChange(Kopete::OnlineStatus status);

    /**
     * Called by the session when a notification message has been received
     */
    void slotServerNotification(const TQString &mesg);

    /** Reimplemented from Kopete::Account */
    void setOnlineStatus(const Kopete::OnlineStatus& status,
            const TQString &reason = TQString());
    void setAway(bool away, const TQString&reason = TQString());

private:
    /** Current online status */
    Kopete::OnlineStatus status;

    /** A meanwhile session */
    MeanwhileSession *m_session;

    /* The user id for this account */
    TQString m_meanwhileId;
};

#endif