Logo Search packages:      
Sourcecode: kmess version File versions  Download package

currentaccount.h

/***************************************************************************
                          currentaccount.h  -  description
                             -------------------
    begin                : Sun Jan 5 2003
    copyright            : (C) 2003 by Mike K. Bennett
    email                : mkb137b@hotmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 CURRENTACCOUNT_H
#define CURRENTACCOUNT_H

#include "account.h"

#include <qptrlist.h>
#include <qstringlist.h>
#include <qtimer.h>

#include "contact/contactbase.h"

// Forward declarations
class InvitedContact;
class KMessTest;
class ContactList;
class MsnSwitchboardConnection;

/**
 * @brief Data class for session information of the logged in user.
 *
 * When the user logs into MSN Messenger, the data of the Account class
 * is copied to this class with the copyAccount() method.
 * During the session, all modifications are stored here.
 * When the user disconnects, the data is copied back and eventually saved to disk.
 *
 * This class also stores session-related data While the user is connected.
 * This includes the contact list state.
 *
 * @author Mike K. Bennett
 * @ingroup Root
 */
00049 class CurrentAccount : public Account
{
  Q_OBJECT

  friend class KMessTest;

  public:
    // Add an unknown contact to the invited contact list
    InvitedContact *         addInvitedContact( const QString &handle, const QString &friendlyName, const uint capabilities );
    // Receive notice that some emails were deleted
    void                     changeNoEmails( int change );
    // Copy an account
    virtual void             copyAccount( const Account *account );
    // Delete the instance of the contact list
    static void              destroy();
    // Return whether or not to autoreply to messages
    bool                     getAutoreply() const;
    // Return the compose command.
    const QString&           getComposeCommand() const;
    // Return a contact by handle
    ContactBase              *getContactByHandle(const QString &handle) const;
    // Return a contact's name by handle
    QString                  getContactFriendlyNameByHandle(const QString &handle) const;
    // Return the contact list as read-only
    const ContactList *      getContactList() const;
    // Return the contact which was last dragged.
    const ContactBase*       getContactLastDragged() const;
    // Return the email URL
    const QString&           getEmailUrl() const;
    // Return the external IP, as seen from the MSN server.
    const QString&           getExternalIp() const;
    // Return the external port, as seen from the MSN server.
    uint                     getExternalPort() const;
    // Return the inbox command.
    const QString&           getInboxCommand() const;
    // Return the local IP.
    const QString&           getLocalIp() const;
    // Return the number of email in the inbox
    int                      getNoEmails() const;
    // Return the user's staus
    QString                  getStatus() const;
    // Return whether the given contact exists in the contact list.
    bool                     hasContactInList(const QString &handle) const;
    // Return a singleton instance of the current account
    static CurrentAccount*   instance();
    // Open e-mail with the given command, url, and folder
    void                     openMail(const QString&  command, const QString&  folder, const QString&  url);
    // Open e-mail at the compose page with the given contact handle
    void                     openMailAtCompose(QString contactHandle);
    // Open e-mail at the user's inbox
    void                     openMailAtInbox();
    // Set some account information
    void                     setAccountInformation( QString authorization, QString preferredEmail,
                                                    QString sid, bool emailSupported, QString externalIp, uint externalPort,
                                                    QString internalIp );
    // Set whether or not to autoreply to a contact's chat message.
    void                     setAutoreply(bool autoreply);
    // Set compose properties
    void                     setComposeInformation( QString command, QString folder, QString url );
    // Store the contact list, maintained by the MsnNotificationConnection class
    void                     setContactList(const ContactList *contactList);
    // Set inbox properties.
    void                     setInboxInformation( QString command, QString folder, QString url );
    // Set initial email information
    void                     setInitialEmailInformation( int noEmailsInInbox, int noEmailsInOtherFolders );
    // Set the e-mail post url
    void                     setEmailUrl( QString postUrl );
    // Set the number of emails
    void                     setNoEmails( int noEmails );
    // Set the user's status
    void                     setStatus( QString status );

  private: // Private methods
    // The constructor
                             CurrentAccount();
    // The destructor
                            ~CurrentAccount();
    // Calculate the length of the session with the notification server.
    int                      getSessionLength() const;

  private slots: // Private slots
    // An invited contact left all chats.
    void                     slotInvitedContactLeftAllChats( ContactBase *contactBase );

  private:  // private methods
    // Find an invited contact by handle
    InvitedContact *         getInvitedContactByHandle(const QString &handle) const;
    // Start a process
    void                     startProcess(QString command);

  private: // Private attributes
    // The MS Passport authorization used to access hotmail.
    QString                  authorization_;
    // Whether or not the program should autoreply to chat messages.
    bool                     autoreply_;
    // The HTTPS command to use when connecting to hotmail's compose.
    QString                  composeCommand_;
    // The folder for email composition, i.e. cgi-bin/compose
    QString                  composeFolder_;
    // The URL to go to when opening the compose folder.
    QString                  composeUrl_;
    // The contact list of the current account
    const ContactList       *contactList_;
    // The user's preferred email URL (i.e. www.hotmail.com)
    QString                  emailUrl_;
    // Our (external) IP address seen from the MSN server.
    QString                  externalIp_;
    // Our (external) Port seen from the MSN server.
    uint                     externalPort_;
    // The HTTPS command to use when connecting to the inbox.
    QString                  inboxCommand_;
    // The inbox folder, i.e. /cgi-bin/HoTMaiL.
    QString                  inboxFolder_;
    //The URL of the inbox
    QString                  inboxUrl_;
    // The instance of the singleton account
    static CurrentAccount   *instance_;
    // The list of invited contacts, not part of the MSN ContactList of the user.
    QPtrList<ContactBase>    invitedContacts_;
    // The local IP address
    QString                  localIp_;
    // The time at which the user synchronized with the notification server.
    unsigned int             loginTime_;
    // The number of emails in the user's inbox.
    int                      noEmails_;
    // The email address considered by the server to be the user's preferred address.  I don't know when it differs from the handle.
    QString                  preferredEmail_;
    // A value used to access the user's hotmail account.
    QString                  sid_;
    // The online status of the user.
    QString                  status_;

  signals: // Public signals
    // Signal that the account went invisible
    void                     accountInvisible();
    // Signal that the account went offline
    void                     accountOffline();
    // Signal that the account went online
    void                     accountOnline();
    // Signal that the number of emails has changed
    void                     changedNoEmails();
    // Signal that the user's status has changed
    void                     changedStatus();
};

#endif

Generated by  Doxygen 1.6.0   Back to index