Logo Search packages:      
Sourcecode: kmess version File versions


                          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.                                   *
 *                                                                         *


#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

    // Client capabilities for CHG command and getCapabilities() method
    enum MsnClientCapabilities
      MSN_CAP_WIN_MOBILE     = 0x01,       // Uses a Windows Mobile device (shows phone icon in buddy list).
      MSN_CAP_INK_GIF        = 0x04,       // Supports handwritten messages in GIF format
      MSN_CAP_INK_ISF        = 0x08,       // Supports handwritten messages in ISF format
      MSN_CAP_VIDEO_CHAT     = 0x10,       // Supports video chats, ie; webcam is connected and shared.
      MSN_CAP_MULTI_PACKET   = 0x20,       // Supports multi packet messages.
      MSN_CAP_MSN_MOBILE     = 0x40,       // Has an MSN Mobile device you can page them on  (MSN6 displays a yellow icon
                                        // if they're offline. Equivalent to the 'BPR MOB Y' setting).
      MSN_CAP_MSN_DIRECT     = 0x80,       // Has an MSN Direct device you can direct-page them on (equivalent to BPR WWE setting).
      MSN_CAP_WEB_CLIENT     = 0x200,      // Client is "webmessenger.msn.com"
      MSN_CAP_MSO_CLIENT     = 0x800,      // Client is Office Live client, or internal Microsoft client.
      MSN_CAP_LIVE_SPACE     = 0x1000,     // User has an Windows Live space.
      MSN_CAP_DIRECT_IM      = 0x4000,     // Supports direct im (no switchboard)
      MSN_CAP_WINKS          = 0x8000,     // Supports Winks
      MSN_CAP_SEARCH         = 0x10000,    // Supports MSN shared search
      MSN_CAP_BOT            = 0x20000,    // Set by the server if the account has been provisioned by MSN as being a Bot account (and thus have its limitations removed).
      MSN_CAP_VOICE_IM       = 0x40000,    // Supports Voice Clips
      MSN_CAP_SECURE_IM      = 0x80000,    // Supports secure channel to send secure messages
      MSN_CAP_SIP_INVITE     = 0x100000,   // The client supports unknown SIP-based communications.
      MSN_CAP_FOLDER_SHARING = 0x400000,   // Supports folder sharing
      MSN_CAP_MSN60          = 0x10000000, // The client supports client protocols up to and including MSNC1 (msn6   compatible).
      MSN_CAP_MSN61          = 0x20000000, // The client supports client protocols up to and including MSNC2 (msn6.1 compatible).
      MSN_CAP_MSN62          = 0x30000000, // The client supports client protocols up to and including MSNC3 (msn6.2 compatible).
      MSN_CAP_MSN70          = 0x40000000, // The client supports client protocols up to and including MSNC4 (msn7   compatible).
      MSN_CAP_MSN75          = 0x50000000, // The client supports client protocols up to and including MSNC5 (msn7.5 compatible).
      MSN_CAP_MSN90          = 0x60000000  // The client supports client protocols up to and including MSNC6 (WL 8.0 compatible).

  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);

  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 );


Generated by  Doxygen 1.6.0   Back to index