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

contactbase.h

/***************************************************************************
                          contactbase.h  -  description
                             -------------------
    begin                : Thu Jan 16 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 CONTACTBASE_H
#define CONTACTBASE_H

#include <qmap.h>
#include <qregexp.h>

#include "../network/msnswitchboardconnection.h"


class ApplicationList;


/**
 * @brief Base class of a contact, used for polymorphism with invited contacts.
 *
 * This class only stores the generic properties such as account handle, and friendly name.
 * The remaining information is available in the Contact or InvitedContact class.
 * The online state is determined with the getStatus() method, which is implemented in both derived classes.
 *
 * For proper handling of the peer-to-peer invitations,
 * this class also stores the MsnSwitchboardConnection sessions the contact is active in.
 * The ApplicationList contains all application invitations started with the contact.
 * These classes are controlled from the ChatMaster class.
 *
 * @author Mike K. Bennett
 * @ingroup Contact
 */
00045 class ContactBase : public QObject
{
  Q_OBJECT

  public:
    /**
     * @brief The values for the bitwise client capabilities flag returned by getCapabilities().
     *
     * This flag is used to advertise the features supported by a client.
     * It's sent with the <code>CHG</code> command at the MsnNotificationConnection.
     */
00056     enum MsnClientCapabilities
    {
00058       MSN_CAP_WIN_MOBILE     = 0x01,       ///< <code>0x01</code>, the client is a Windows Mobile device, display an phone icon overlay in buddy list.
00059       MSN_CAP_INK_GIF        = 0x04,       ///< <code>0x04</code>, the client supports handwritten messages in GIF format.
00060       MSN_CAP_INK_ISF        = 0x08,       ///< <code>0x08</code>, the client supports handwritten messages in ISF format.
00061       MSN_CAP_VIDEO_CHAT     = 0x10,       ///< <code>0x10</code>, the client supports video chats; the webcam is connected and shared.
00062       MSN_CAP_MULTI_PACKET   = 0x20,       ///< <code>0x20</code>, the client supports multi-packet MIME messages.
00063       MSN_CAP_MSN_MOBILE     = 0x40,       ///< <code>0x40</code>, the contact has a MSN Mobile device you can page them on  (MSN6 displays a yellow icon if they're offline. This is equivalent to the <code>BPR MOB Y</code> setting).
00064       MSN_CAP_MSN_DIRECT     = 0x80,       ///< <code>0x80</code>, the user has a MSN Direct device you can direct-page them on (equivalent to <code>BPR WWE</code> setting).
00065       MSN_CAP_WEB_CLIENT     = 0x200,      ///< <code>0x200</code>, the client is http://webmessenger.msn.com/.
00066       MSN_CAP_MSO_CLIENT     = 0x800,      ///< <code>0x800</code>, the client is Office Live client, or internal Microsoft client.
00067       MSN_CAP_LIVE_SPACE     = 0x1000,     ///< <code>0x1000</code>, the user has an Windows Live space.
00068       MSN_CAP_DIRECT_IM      = 0x4000,     ///< <code>0x4000</code>, the client supports direct-im (chats without a switchboard connection)
00069       MSN_CAP_WINKS          = 0x8000,     ///< <code>0x8000</code>, the client supports Winks.
00070       MSN_CAP_SEARCH         = 0x10000,    ///< <code>0x10000</code>, the client supports MSN shared search.
00071       MSN_CAP_BOT            = 0x20000,    ///< <code>0x20000</code>, this is set by the server if the account has been provisioned by MSN as being a Bot account (and thus have its limitations removed).
00072       MSN_CAP_VOICE_IM       = 0x40000,    ///< <code>0x40000</code>, the client supports Voice Clips.
00073       MSN_CAP_SECURE_IM      = 0x80000,    ///< <code>0x80000</code>, the client supports secure channel to send secure messages.
00074       MSN_CAP_SIP_INVITE     = 0x100000,   ///< <code>0x100000</code>, the client supports unknown SIP-based communications.
00075       MSN_CAP_FOLDER_SHARING = 0x400000,   ///< <code>0x400000</code>, the client supports folder sharing.
00076       MSN_CAP_MSN60          = 0x10000000, ///< <code>0x10000000</code>, the client supports the P2P protocol features of MSNC1 (introduced with MSN 6.0).
00077       MSN_CAP_MSN61          = 0x20000000, ///< <code>0x20000000</code>, the client supports the P2P protocol features of MSNC2 (introduced with MSN 6.1).
00078       MSN_CAP_MSN62          = 0x30000000, ///< <code>0x30000000</code>, the client supports the P2P protocol features of MSNC3 (introduced with MSN 6.2).
00079       MSN_CAP_MSN70          = 0x40000000, ///< <code>0x40000000</code>, the client supports the P2P protocol features of MSNC4 (introduced with MSN 7.0).
00080       MSN_CAP_MSN75          = 0x50000000, ///< <code>0x50000000</code>, the client supports the P2P protocol features of MSNC5 (introduced with MSN 7.5).
00081       MSN_CAP_MSN80          = 0x60000000  ///< <code>0x60000000</code>, the client supports the P2P protocol features of MSNC6 (introduced with WLM 8.0).
    };


  public: // Public methods
    // The destructor
    virtual             ~ContactBase();
    // Add a custom emoticon definition
    void                 addEmoticonDefinition(const QString &emoticonCode, const QString &msnObjectDataHash);
    // Add a custom emoticon definition
    void                 addEmoticonFile(const QString &msnObjectDataHash, const QString &filename);
    // Register the contact as participant in the chat session
    void                 addSwitchboardConnection( const MsnSwitchboardConnection *connection );
    // Initialize an application list for the contact.
    ApplicationList     *createApplicationList();
    // Return the application list of the contact
    ApplicationList     *getApplicationList() const;
    // Return the capablities of the client the contact uses.
    uint                 getCapabilities() const;
    // Return the default contact picture path
    QString              getContactDefaultPicturePath() const;
    // Return the path to the contact's picture
    virtual QString      getContactPicturePath() const = 0;
    // Return the custom emoticon code for an msn object
    const QString &      getEmoticonCode(const QString &msnObjectDataHash) const;
    // Return the custom emoticon search pattern.
    const QRegExp &      getEmoticonPattern() const;
    // Return the custom emoticon replacements.
    const QMap<QString,QString> & getEmoticonReplacements() const;
    // Return the contact's friendly name
    virtual QString      getFriendlyName() const;
    // Return the contact's handle
    QString              getHandle() const;
    // Return the search pattern for pending custom emoticons.
    const QRegExp &      getPendingEmoticonPattern() const;
    // Return the contact's status
    virtual QString      getStatus() const = 0;
    // Return the list of switchboard connections
    const QPtrList<MsnSwitchboardConnection> getSwitchboardConnections() const;
    // Returns whether the contact has an application list initialized.
    bool                 hasApplicationList() const;
    // Returns whether the contact's client supports the given MSNP2P version
    bool                 hasP2PSupport( MsnClientCapabilities minimalVersion = MSN_CAP_MSN60 ) const;
    // Return true if the contact is offline
    bool                 isOffline() const;
    // Return true if the contact is online
    bool                 isOnline() const;
    // Unregister the contact as participant, contact has left the chat.
    void                 removeSwitchboardConnection( const MsnSwitchboardConnection *connection, bool userInitiated = false );
    // Set the capabilities flag of the contact's msn client.
    void                 setCapabilities(uint capabilities);

  protected: // Protected methods
    // The constructor
                         ContactBase(QString handle, QString friendlyName, uint capabilities = 0);

  private slots:
    // The application list completed aborting it's applications.
    void                 slotApplicationListAborted();

  protected: // Protected attributes
    // The capabilities of the client
    uint                 capabilities_;
    // The custom emoticons for the contact.
    QMap<QString,QString> customEmoticons_;
    // The emoticon regexp
    QRegExp              emoticonRegExp_;
    // The contact's friendly name
    QString              friendlyName_;
    // The contact's handle
    QString              handle_;
    // The pending custom emoticons for the contact.
    QMap<QString,QString> pendingEmoticons_;
    // The regexp for pending custom emoticons
    QRegExp              pendingRegExp_;
    // The contact's online status
    QString              status_;


  private:  // private properties
    // The list of peer-to-peer application invitations.
    ApplicationList                   *applicationList_;
    // The list of chat sessions the contact participates in.
    QPtrList<MsnSwitchboardConnection> chatSessions_;

  signals: // Public signals
    // Signal that the contact's friendly name changed
    void                 changedFriendlyName();
    // Signal that the contact's picture path has changed
    void                 changedPicture();
    // Signal that the contact's status changed
    void                 changedStatus();
    // Signal that the contact left all chats
    void                 leftAllChats( ContactBase *contact );
};

#endif

Generated by  Doxygen 1.6.0   Back to index