File indexing completed on 2024-04-21 04:04:42
0001 /* 0002 * jabbercontact.cpp - Regular Kopete Jabber protocol contact 0003 * 0004 * Copyright (c) 2002-2004 by Till Gerken <till@tantalo.net> 0005 * 0006 * Kopete (c) by the Kopete developers <kopete-devel@kde.org> 0007 * 0008 * ************************************************************************* 0009 * * * 0010 * * This program is free software; you can redistribute it and/or modify * 0011 * * it under the terms of the GNU General Public License as published by * 0012 * * the Free Software Foundation; either either version 2 0013 of the License, or (at your option) any later version.of the License, or * 0014 * * (at your option) any later version. * 0015 * * * 0016 * ************************************************************************* 0017 */ 0018 0019 #ifndef JABBERCONTACT_H 0020 #define JABBERCONTACT_H 0021 0022 #include "jabberbasecontact.h" 0023 #include "xmpp_vcard.h" 0024 0025 // #include "kopetechatsession.h" // needed for silly Kopete::ContactPtrList 0026 0027 #include <QList> 0028 0029 class JabberChatSession; 0030 class QTimer; 0031 0032 class JabberContact : public QObject 0033 { 0034 0035 Q_OBJECT 0036 0037 public: 0038 0039 JabberContact (const XMPP::RosterItem &rosterItem, 0040 JabberAccount *account, const QString &legacyId = QString()); 0041 0042 ~JabberContact(); 0043 0044 /** 0045 * Create custom context menu items for the contact 0046 * FIXME: implement manager version here? 0047 */ 0048 // QList<QAction *> *customContextMenuActions (); 0049 0050 /** 0051 * Start a rename request. 0052 */ 0053 void rename ( const QString &newName ); 0054 0055 /** 0056 * Deal with an incoming message for this contact. 0057 */ 0058 void handleIncomingMessage ( const XMPP::Message &message ); 0059 0060 /** 0061 * Create a message manager for this contact. 0062 * This variant is a pure single-contact version and 0063 * not suitable for groupchat, as it only looks for 0064 * managers with ourselves in the contact list. 0065 */ 0066 // Kopete::ChatSession *manager ( Kopete::Contact::CanCreateFlags ); 0067 0068 0069 bool isContactRequestingEvent( XMPP::MsgEvent event ); 0070 0071 QString lastReceivedMessageId () const; 0072 0073 public slots: 0074 0075 /** 0076 * Remove this contact from the roster 0077 */ 0078 void deleteContact (); 0079 0080 /** 0081 * Sync Groups with server 0082 * 0083 * operations are alctually performed in sloDelayedSync() 0084 */ 0085 void sync(unsigned int); 0086 0087 /** 0088 * This is the JabberContact level slot for sending files. 0089 * 0090 * @param sourceURL The actual KUrl of the file you are sending 0091 * @param fileName (Optional) An alternate name for the file - what the 0092 * receiver will see 0093 * @param fileSize (Optional) Size of the file being sent. Used when sending 0094 * a nondeterminate file size (such as over a socket) 0095 */ 0096 virtual void sendFile( const KUrl &sourceURL = KUrl(), 0097 const QString &fileName = QString(), uint fileSize = 0L ); 0098 0099 /** 0100 * Update the vCard on the server. 0101 * @todo is that still used ? 0102 */ 0103 void slotSendVCard(); 0104 0105 /** 0106 * Set contact photo. 0107 * @param path Path to the photo. 0108 */ 0109 void setPhoto(const QString &photoPath); 0110 0111 /** 0112 * this will start a voice call to the contact 0113 */ 0114 void voiceCall(); 0115 0116 private slots: 0117 0118 /** 0119 * Send type="subscribed" to contact 0120 */ 0121 void slotSendAuth (); 0122 0123 /** 0124 * Send type="subscribe" to contact 0125 */ 0126 void slotRequestAuth (); 0127 0128 /** 0129 * Send type="unsubscribed" to contact 0130 */ 0131 void slotRemoveAuth (); 0132 0133 /** 0134 * Change this contact's status 0135 */ 0136 void slotStatusOnline (); 0137 void slotStatusChatty (); 0138 void slotStatusAway (); 0139 void slotStatusXA (); 0140 void slotStatusDND (); 0141 void slotStatusInvisible (); 0142 0143 /** 0144 * Select a new resource for the contact 0145 */ 0146 void slotSelectResource (); 0147 0148 void slotChatSessionDeleted ( QObject *sender ); 0149 0150 /** 0151 * Check if cached vCard is recent. 0152 * Triggered as soon as Kopete changes its online state. 0153 */ 0154 void slotCheckVCard (); 0155 0156 /** 0157 * Triggered from a timer, requests the vCard. 0158 * Timer is initiated by @ref slotCheckVCard. 0159 */ 0160 void slotGetTimedVCard (); 0161 0162 /** 0163 * Passes vCard on to parsing function. 0164 */ 0165 void slotGotVCard (); 0166 0167 /** 0168 * Get information about last activity of the contact. 0169 * Triggered as soon as Kopete goes online or the contact goes offline. 0170 */ 0171 // void slotCheckLastActivity ( Kopete::Contact *, const Kopete::OnlineStatus &, const Kopete::OnlineStatus & ); 0172 0173 /** 0174 * Triggered from a timer, requests last activity information. 0175 * Timer is initiated by @ref slotCheckLastActivity. 0176 */ 0177 void slotGetTimedLastActivity (); 0178 0179 /** 0180 * Updates activity information. 0181 */ 0182 void slotGotLastActivity (); 0183 0184 /** 0185 * Display a error message if the vCard sent was unsuccessful. 0186 */ 0187 void slotSentVCard(); 0188 0189 /** 0190 * The service discovery on that contact is finished 0191 */ 0192 void slotDiscoFinished(); 0193 0194 /** 0195 * actually perform operations of sync() with a delay. 0196 * slot received by the syncTimer. 0197 */ 0198 void slotDelayedSync(); 0199 private: 0200 0201 /** 0202 * Create a message manager for this contact. 0203 * This variant is a pure single-contact version and 0204 * not suitable for groupchat, as it only looks for 0205 * managers with ourselves in the contact list. 0206 * Additionally to the version above, this one adds 0207 * a resource constraint that has to be matched by 0208 * the manager. If a new manager is created, the given 0209 * resource is preselected. 0210 */ 0211 JabberChatSession *manager ( const QString &resource/*, Kopete::Contact::CanCreateFlags*/ ); 0212 0213 /** 0214 * Create a message manager for this contact. 0215 * This version is suitable for groupchat as it 0216 * looks for a message manager with a given 0217 * list of contacts as members. 0218 */ 0219 JabberChatSession *manager ( /*Kopete::ContactPtrList chatMembers, Kopete::Contact::CanCreateFlags*/ ); 0220 0221 /** 0222 * Sends subscription messages. 0223 */ 0224 void sendSubscription (const QString& subType); 0225 0226 /** 0227 * Sends a presence packet to this contact 0228 */ 0229 void sendPresence ( const XMPP::Status status ); 0230 0231 /** 0232 * This variable keeps a list of message managers. 0233 * It is required to locate message managers by 0234 * resource name, if one account is interacting 0235 * with several resources of the same contact 0236 * at the same time. Note that this does *not* 0237 * apply to groupchats, so this variable 0238 * only contains classes of type JabberChatSession. 0239 * The casts in manager() and slotChatSessionDeleted() 0240 * are thus legal. 0241 */ 0242 QList<JabberChatSession*> mManagers; 0243 0244 /** 0245 * Indicates whether the vCard is currently 0246 * being updated or not. 0247 */ 0248 bool mVCardUpdateInProgress :1; 0249 0250 bool mRequestComposingEvent :1; 0251 bool mRequestOfflineEvent :1; 0252 bool mRequestDisplayedEvent :1; 0253 bool mRequestDeliveredEvent :1; 0254 bool mRequestGoneEvent :1; 0255 /** 0256 * tell if the disco#info has been done for this contact. 0257 */ 0258 bool mDiscoDone :1; 0259 0260 QString mLastReceivedMessageId; 0261 QTimer *m_syncTimer; 0262 0263 }; 0264 0265 #endif