Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / protocols / skype / skypeaccount.h
blob0802925c376f93487362eed11e1da99fcd82ad70
1 /* This file is part of the KDE project
2 Copyright (C) 2005 Michal Vaner <michal.vaner@kdemail.net>
3 Copyright (C) 2008-2009 Pali Rohár <pali.rohar@gmail.com>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
20 #ifndef SKYPEACCOUNT_H
21 #define SKYPEACCOUNT_H
23 #include <kopeteaccount.h>
24 #include <kactionmenu.h>
25 #include <kmenu.h>
27 class SkypeProtocol;
28 class QString;
29 class SkypeAccountPrivate;
30 class SkypeContact;
31 class SkypeChatSession;
33 namespace Kopete {
34 class MetaContact;
35 class OnlineStatus;
36 class Message;
39 #define DBUS_SESSION 0
40 #define DBUS_SYSTEM 1
42 /**
43 * @author Michal Vaner
44 * @author Pali Rohár
45 * @short Skype account
46 * Account to use external skype program. At this time, it only supports one skype account at one, may be more in future.
48 class SkypeAccount : public Kopete::Account
50 Q_OBJECT
51 private:
52 ///Some internal things
53 SkypeAccountPrivate *d;
54 ///Constructs list of users from their ID list. Have to be deleted later!
55 QList<Kopete::Contact*> *constructContactList(const QStringList &users);
56 private slots:
57 /**
58 * This sets the right icon for the status - online
60 void wentOnline();
61 /**
62 * This changes the account icon to offline
64 void wentOffline();
65 /**
66 * This changes the account icon to away
68 void wentAway();
69 /**
70 * This changes the account icon to not available
72 void wentNotAvailable();
73 /**
74 * This changes the account icon to Do not disturb
76 void wentDND();
77 /**
78 * This changes the status icon of account to Invisible
80 void wentInvisible();
81 /**
82 * This changes the status indicator to Skype me
84 void wentSkypeMe();
85 /**
86 * The status changed to actually connecting
88 void statusConnecting();
89 /**
90 * This adds user to the contact list if it is not there
91 * @param name The skype name of the contact
92 * @param group The skype group name, where is user
94 void newUser(const QString &name, int group);
95 /**
96 * This is used for receiving messages from skype network
97 * @param user The user that sent it
98 * @param message The text of the message
99 * @param messageId Id of that message
101 void receivedIm(const QString &user, const QString &message, const QString &messageId);
103 * New cal to show (or not, depending on setup) the call control window.
104 * @param callId ID of the new call
105 * @param userId User that is on the other end. If conference, list of IDs divided by spaces.
107 void newCall(const QString &callId, const QString &userId);
109 * This one sets name of myself
110 * @param name What the new name is.
112 void setMyselfName(const QString &name);
114 * This one keeps track of chat sessions that know their chat id
115 * @param oldId The old chat ID, or empty if no chat ID was known before
116 * @param newId The new chat ID, or empty if the chat just exists
117 * @param sender Pointer to the session
119 void setChatId(const QString &oldId, const QString &newId, SkypeChatSession *sender);
121 * Some message is meing sent out by Skype, it should be showed
122 * @param body Text of the message
123 * @param chat Id of the chat it was sent to
125 void sentMessage(const QString &body, const QString &chat);
127 * An Id of some message is known, use it
128 * @param messageId New id of that message
130 void gotMessageId(const QString &messageId);
132 * This is used to group conference call participants together
133 * @param callId What call to add to the group
134 * @param groupIt to what group to add it
136 void groupCall(const QString &callId, const QString &groupId);
138 * Remove that call from list
139 * @param callId what call
141 void removeCall(const QString &callId);
143 * Remove reference to a call group
144 * @param groupId What group to remove
146 void removeCallGroup(const QString &groupId);
148 * Delete skype group
149 * @param group kopete group
151 void deleteGroup (Kopete::Group * group);
153 * Rename skype group
154 * @param group kopete group
155 * @param oldname old kopete group name
157 void renameGroup (Kopete::Group * group, const QString &oldname );
158 protected:
160 * Creates new skype contact and adds it into the parentContact.
161 * @param contactID ID of the contact (the skype name)
162 * @param parentContact Metacontact to add it into.
163 * @return True if it worked, false otherwise.
165 virtual bool createContact(const QString &contactID, Kopete::MetaContact *parentContact);
167 * This simulates contacts going on and offline in sync with the account's status changes
169 void updateContactStatus();
170 public:
172 * Constructor.
173 * @param protocol The skype protocol pointer.
175 SkypeAccount(SkypeProtocol *protocol, const QString& accountID);
177 * Destructor
179 ~SkypeAccount();
181 * Finds contact of given id
182 * @param id id of the wanted contact
183 * @return eather pointer to that contact or 0L of it was not found.
185 SkypeContact *contact(const QString &id);
187 * How to launch the Skype
189 int launchType;
191 * Is this verson of protocol able to create call conferences?
193 bool ableMultiCall();
195 * Is it possible to alter the authorization now?
197 bool canAlterAuth();
199 * How shoul kopete authorize it self? (empty means as Kopete)
201 QString author;
203 * This saves properties to the config file
205 void save();
207 * Prepares this contact for life and integrates it into this account. Should be called only by the contact in its constructor.
208 * @param conntact The contact to prepare
210 void prepareContact(SkypeContact *contact);
211 ///Can we comunicate with the skype? (not with the network, just with the program)
212 bool canComunicate();
213 ///returns the protocol
214 SkypeProtocol * protocol();
216 * @return Is the HitchHike mode enabled or not?
217 * @see setHitchHike
219 bool getHitchHike() const;
221 * @return Is the MarkRead mode enabled or not?
222 * @see setMarkRead
224 bool getMarkRead() const;
226 * Is the scan for unread message on login enabled?
227 * @return Is it enabled or not?
228 * @see setSearchForUnread
230 bool getScanForUnread() const;
232 * @return true if this user already has opened chat session, false if he doesn't have opened chat session or the user do not exist
233 * @param userId ID of the user in interest
235 bool userHasChat(const QString &userId);
237 * @return Should a control window be showed for calls?
239 bool getCallControl() const;
241 * Is that call incoming or not?
242 * @param callId What call you want to know?
243 * @return true if the call is incoming call (someone calls you), false otherwise (outgoing, not a call at all..)
245 bool isCallIncoming(const QString &callId);
247 * @return The time after the call finished to auto-closing the window. If auto-closing is disabled, 0 is returned
248 * @see setCallWindowTimeout
250 int closeCallWindowTimeout() const;
252 * @return Returns name that shouls be showed by a call window
254 QString getUserLabel(const QString &userId);
256 * Are pings to Skype enabled?
257 * @return You guess..
259 bool getPings() const;
261 * What bus is set to use now?
262 * @return 0 as session bus, 1 as system wide
264 int getBus() const;
266 * How long does it try to connect to newly started skype, until it gives up (seconds)
268 int getLaunchTimeout() const;
270 * What is the command that launches skype?
272 const QString &getSkypeCommand() const;
274 * Do we wait before connecting?
276 int getWaitBeforeConnect() const;
278 * Do we have that chat opened?
279 * @param chatId What chat are you interested in?
281 bool chatExists(const QString &chatId);
283 * This one returns contact of that name. If that contact does not exist in the contact list, a temporary one is created
284 * @param userId ID of that user
286 SkypeContact *getContact(const QString &userId);
288 * @param messageId ID of a message
289 * @return ID of chat the message belongs to. If no such message exists, the result is not defined.
291 QString getMessageChat(const QString &messageId);
293 * This will mark last active chat (last that sent out some message). It will be set an ID soon after that, user will not have time to write another message anyway
294 * @param session Pointer to that chat session
296 void registerLastSession(SkypeChatSession *session);
298 * Create a chat with given members
299 * @param users Comma sepparated list of members
300 * @return ID of the chat
302 QString createChat(const QString &users);
304 * Should chat leave when it's window is closed?
306 bool leaveOnExit() const;
308 * Returns the call that should be executed before making a call.
309 * @return The command or empty string if nothing should be executed
311 QString startCallCommand() const;
313 * Should we wait for the startCallCommand to finish before making the call.
315 bool waitForStartCallCommand() const;
317 * The command that should be executed after the call is finished.
318 * @return The command or empty string if user does not want to execute anything.
320 QString endCallCommand() const;
322 * Should be tha command executed only for the last call?
324 bool endCallCommandOnlyLast() const;
326 * Command that should be executed on incoming call, or empty string if nothing to execute
328 QString incomingCommand() const;
330 * Registers this contact to the skype contact list
331 * @param contactId What user should be added?
333 void registerContact(const QString &contactId);
335 * returns how is user authorized
336 * @return 0 if he is authorized, 1 if not and 2 if he is blocked
338 int getAuthor(const QString &contactId);
340 * Disconnects from server.
342 virtual void disconnect();
344 * Sets online status to away/online.
345 * @param away If true, it sets to away, otherwise it sets to online.
346 * @param reason Message to set. Ignored with skype as it does not support away messages. (Or I don't know about it))
348 virtual void setAway(bool away, const QString &reason);
350 * Skype account has costum status menu
352 virtual bool hasCustomStatusMenu() const;
354 * Per-protocol actions for the systray and the status bar
356 virtual void fillActionMenu( KActionMenu *actionMenu );
358 * This will return ID of the actual user this one that uses this skype)
360 QString getMyselfSkypeName();
362 * Call it when contact move between group
364 void MovedBetweenGroup(SkypeContact *contact);
366 * Open skype file transfer dilog to send file via skype
368 void openFileTransfer(const QString &user, const QString &url = QString::null);
369 public slots:
371 * Sets online status for the account.
372 * @param status Status to set.
373 * @param reason Away message. Ignored by skype.
375 virtual void setOnlineStatus( const Kopete::OnlineStatus &status , const Kopete::StatusMessage &reason = Kopete::StatusMessage(), const OnlineStatusOptions& options = None);
376 virtual void setStatusMessage(const Kopete::StatusMessage& statusMessage);
378 * Connect to the skype with given status
379 * @param status The status to connect with. If it is something unusual (like offline or something unknown), online is used
381 virtual void connect( const Kopete::OnlineStatus& Status = Kopete::OnlineStatus() );
383 * This notifies contact of some change of its information
384 * @param contact What contact is it?
385 * @param change And what happende.
387 void updateContactInfo(const QString &contact, const QString &change);
389 * This will send message by the skype connection. Will take care of all notifications when it is done and so. (means it will emit messageSent when it is sent)
390 * @param message What to send.
391 * @param chat Chat to send it to. If it is empty, it is sent just to that person listed in the message
393 void sendMessage(Kopete::Message &message, const QString &chat);
395 * Enables or disables the HitchHike mode of getting messages. If it is enabled, a new message to unstarted chat will be showed. If not, they will be ignored and you will have to open them in Skype
396 * @param value True enables HitchHike mode, false disables.
397 * @see getHitchHike
399 void setHitchHike(bool value);
401 * Enables reading messages by kopete. If it is on, all messages showed in Kopete will be marked as read, if disable, you will have to read them in Skype/something else.
402 * If HitchHike mode is disabled, messages that creates chats are NOT marked as read, because they are not showed.
403 * @param value Enable or disable the mode
404 * @see getMarkRead
405 * @see getHitchHake
406 * @see setHitchHike
408 void setMarkRead(bool value);
410 * Set if there should be scan for unread messages when kopete connects to Skype.
411 * @param value Enable or disable the scan.
412 * @see getScanForUnread
414 void setScanForUnread(bool value);
416 * Make a call to that user
417 * @param user To who we call.
419 void makeCall(SkypeContact *user);
421 * Make conference call to more than one user (possibly)
422 * @param users comma separated list of user IDs
424 void makeCall(const QString &users);
426 * Make Test Call - call contact echo123
428 void makeTestCall();
430 * Set if a control window will be showed for calls.
431 * @param value Is it enabled or disabled now?
433 void setCallControl(bool value);
435 * Sets timeout in seconds how long will be call window visible after the call finished. If you want to disable it, set to 0.
437 void setCloseWindowTimeout(int timeout);
439 * Turns pinging skype on/off
440 * If it is on, every second a ping message is sent to skype so track of if Skype is running is still hold. f it is off, skype can be turned off and you won't know it.
441 * @param enabled Are they on or off from now?
443 void setPings(bool enabled);
445 * Sets bus on which Skype listens
446 * @param bus 0 -> session bus, 1 -> system wide bus
448 void setBus(int bus);
450 * Set the timeout for giving up launching Skype
452 void setLaunchTimeout(int seconds);
454 * Set command by what the Skype will be started
456 void setSkypeCommand(const QString &command);
458 * Set if we wait a while before connecting to just started skype
460 void setWaitBeforeConnect(int value);
462 * This should be called with all new chat sessions to connect all signals to them
463 * @param session The chat session
465 void prepareChatSession(SkypeChatSession *session);
467 * This receives a multi-user chat message and delivers it to the chat session
468 * @param chatId What chat should get it
469 * @param boty Text of that message
470 * @param messageId ID of the received message
471 * @param user The one who sent it
473 void receiveMultiIm(const QString &chatId, const QString &body, const QString &messageId, const QString &user);
475 * Set if chat window should close a chat window when you close it
477 void setLeaveOnExit(bool value);
479 * Open chat to the user
480 * @param userId
482 void chatUser(const QString &userId);
484 * Sets the command to be executed before making/accepting call (or empty if nothing)
486 void setStartCallCommand(const QString &value);
488 * Set the command that will be executed when a call is finished
490 void setEndCallCommand(const QString &value);
492 * Do we wait for the command to be executed before making the call?
494 void setWaitForStartCallCommand(bool value);
496 * Should be the end command executed only for the last closed call or for every call that is closed?
498 void setEndCallCommandOnlyForLast(bool value);
500 * Notify me when a call has begun and I should run the start call command
502 void startCall();
504 * Notify me when the call ends to run the end call command
506 void endCall();
508 * Sets a command to be executed for incoming call
510 void setIncomingCommand(const QString &command);
512 * Removes a given contact from skype
514 void removeContact(const QString &contactId);
516 * authorizes a user
517 * @param userId what user
519 void authorizeUser(const QString &userId);
521 * removes authorization from user
522 * @param userId what user
524 void disAuthorUser(const QString &userId);
526 * Blocks a user (no more messages will be accepted)
527 * @param userId what user
529 void blockUser(const QString &userId);
530 signals:
532 * This is emited when the message has been sent by skype
533 * @param messageId Id of the message that has been sent
535 void sentMessage(const QString &messageId);
537 * This slot notifies of connecting/disconnecting. Needed to be sure, if alling is possible.
538 * @param online Are we online now?
540 void connectionStatus(bool online);
544 #endif