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> 4 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. 8 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. 13 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. 18 19 */ 20 #ifndef SKYPE_H 21 #define SKYPE_H 22 23 #include <qobject.h> 24 25 class SkypePrivate; 26 class SkypeAccount; 27 class QDateTime; 28 29 /** 30 * @author Kopete Developers 31 * @author Pali Rohár 32 * This class is internal backend for skype. It provides slots for such things like "send a IM" and so 33 */ 34 class Skype : public QObject 35 { 36 Q_OBJECT 37 private: 38 ///The d pointer for private things 39 SkypePrivate *d; 40 /** 41 * Will try to hitchhike a message. It will hitchhike it, show it in the proper chat session and so on, but just when it is enabled by hitchhike mode and will maker it as read if enabled 42 * @param messageId ID of the message to hitchHike 43 */ 44 void hitchHike(const QString &messageId); 45 private slots: 46 /** 47 * Adds new message do be sent to skype (normaly is sent imediatelly). 48 * If there is no connection to skype, it is created before it is sent. 49 * @param message Message to send to skype 50 * @param deleteQueue If this is true, all message waiting to be sent are deleted and only this one stays in the queue 51 */ 52 void queueSkypeMessage(const QString &message, bool deleteQueue); 53 /** 54 * Listens for closed skype connection 55 */ 56 void closed(int reason); 57 /** 58 * Listens for finishing the connecting attempt and sending the queue if it was successful 59 * @param error - Did it work or was there some error? 60 * @param protocolVer - Version of protocol used by this connection 61 */ 62 void connectionDone(int error, int protocolVer); 63 /** 64 * This one showes an error message 65 * @param message What to write on the dialog box 66 */ 67 void error(const QString &message); 68 /** 69 * This one scans messages from Skype API and acts acordingly to them (changing online status, showing messages.... 70 * @param message What the skype said 71 */ 72 void skypeMessage(const QString &message); 73 /** 74 * This one resets the online status showed on the icon in kopete depending on last values from skype. 75 * Used when the status changes 76 */ 77 void resetStatus(); 78 /** 79 * Makes the Skype search for something and saves what it was to decide later, what to do with it 80 * @param what What are we searching for 81 */ 82 void search(const QString &what); 83 /** 84 * Fix all contact in groups 85 */ 86 void fixGroups(bool loadOnly = false); 87 public: 88 /** 89 * Constructor 90 * @param account The account that this connection belongs to 91 */ 92 Skype(SkypeAccount &account); 93 /** 94 * Destructor 95 */ 96 ~Skype(); 97 ///Can we comunicate with the skype program right now? 98 bool canComunicate(); 99 /** 100 * Enables or disables hitchhake mode of incoming messages 101 * @see SkypeAccount::setHitchHike 102 */ 103 void setHitchMode(bool value); 104 /** 105 * Enables or disables mark read messages mode 106 * @see SkypeAccount::setMarkRead 107 */ 108 void setMarkMode(bool value); 109 /** 110 * Enables/disables scanning for unread messages after login 111 * @see SkypeAccount::setScanForUnread 112 */ 113 void setScanForUnread(bool value); 114 /** 115 * Is that call incoming call? 116 * @param callId What call you mean? 117 * @return true if the call is incoming 118 */ 119 bool isCallIncoming(const QString &callId); 120 /** 121 * Returns ID of chat to what given message belongs 122 * @param messageId Id of the wanted message 123 * @return ID of the chat. For unexisten message the result is not defined. 124 */ 125 QString getMessageChat(const QString &messageId); 126 /** 127 * Returns list of users in that chat without actual user 128 * @param chat ID of that chat you want to know 129 */ 130 QStringList getChatUsers(const QString &chat); 131 /** 132 * This will return ID of the actual user this one that uses this skype 133 */ 134 QString getMyself(); 135 /** 136 * Create a chat with that members 137 * @param users List of users separated by coma (user_1, user_2, user...) 138 * @return Id of the new chat 139 */ 140 QString createChat(const QString &users); 141 /** 142 * Says if the contact should be authorize, not authorized or blocked 143 */ 144 enum AuthorType { 145 Author, 146 Deny, 147 Block 148 }; 149 /** 150 * Ask if the user how is the user authorized 151 * @param contactId What user are you interested in? 152 */ 153 AuthorType getAuthor(const QString &contactId); 154 /** 155 * Is this version of protocol able to create conference calls? 156 */ 157 bool ableConference(); 158 /** 159 * Get group name, where is contact 160 * @param name Skype contact name 161 * @return group id, where is contact 162 */ 163 int getContactGroupID(const QString &name); 164 /** 165 * Remove user from group 166 * @param name Skype contact name 167 * @param groupID Skype group id 168 */ 169 void removeFromGroup(const QString &name, int groupID); 170 /** 171 * Add user to group 172 * @param name Skype contact name 173 * @param groupID Skype group id 174 */ 175 void addToGroup(const QString &name, int groupID); 176 /** 177 * Create Skype group 178 * @param name Group name 179 */ 180 void createGroup(const QString &name); 181 /** 182 * Remove Skype group 183 * @param groupID Skype group id 184 */ 185 void deleteGroup(int groupID); 186 /** 187 * Rename Skype group 188 * @param groupID Skype group id 189 * @param newName New group name 190 */ 191 void renameGroup(int groupID, const QString &newName); 192 /** 193 * Get group id 194 * @param groupname name 195 * @return groupID 196 */ 197 int getGroupID(const QString &groupname); 198 /** 199 * Get group name 200 * @param groupID groupID 201 * @return group name 202 */ 203 QString getGroupName(int groupID); 204 /** 205 * Get Skype display name for contact 206 * @param user Skype user 207 * @return Skype display name 208 */ 209 QString getContactDisplayName(const QString &user); 210 /** 211 * Set Skype display name for contact 212 * @param user Skype user 213 * @param name new Skype display name (empty string is default display name == fullname) 214 */ 215 void setContactDisplayName(const QString &user, const QString &name); 216 /** 217 * Open skype file transfer dilog to send file via skype 218 * @param user Skype user 219 * @url url of local file 220 * @return true if transfer opened 221 */ 222 bool openFileTransfer(const QString &user, const QString &url = QString()); 223 /** 224 * Search for skype contacts 225 * @param string skype user name or email (with "@") 226 * @return all users for string string 227 */ 228 QStringList searchUsers(const QString &string); 229 230 ///Video section 231 232 /** 233 * Check if user has video support 234 * @user for check 235 */ 236 bool supportVideo(const QString &user); 237 238 /** 239 * Start sending video in active call 240 * @callId id of call 241 */ 242 void startSendingVideo(const QString &callId); 243 244 /** 245 * Stop sending video in active video call 246 * @callId id of call 247 */ 248 void stopSendingVideo(const QString &callId); 249 250 public slots: 251 /** 252 * Tell the skype to go online 253 */ 254 void setOnline(); 255 /** 256 * Sets the rich text mood for the user profile 257 */ 258 void setUserProfileRichMoodText(const QString &); 259 /** 260 * Tell the skype to go offline 261 */ 262 void setOffline(); 263 /** 264 * Tell the skype to go offline 265 */ 266 void setAway(); 267 /** 268 * Tell the skype to go not available 269 */ 270 void setNotAvailable(); 271 /** 272 * Tell the skype to go to Do not disturb 273 */ 274 void setDND(); 275 /** 276 * Tell the skype to go to Skype me mode 277 */ 278 void setSkypeMe(); 279 /** 280 * Tell the skype to go invisible 281 */ 282 void setInvisible(); 283 /** 284 * This sets the values of the account. 285 * @see SkypeAccount 286 */ 287 void setValues(int launchType, const QString &appName); 288 /** 289 * Retrieve info of that contact 290 * @param contact What contact wants it 291 */ 292 void getContactInfo(const QString &contact); 293 /** 294 * Asks skype for buddy status of some contact. Buddystatus is some property that ondicates, weather it is in contact list, awaiting authorization, just been mentioned or what exactly happened with it.. 295 * After skype responses, you will get the response by emiting the received signal 296 * @param contact It is the contact id of the user you want to check. 297 */ 298 void getContactBuddy(const QString &contact); 299 /** 300 * Sends a message trough skype, returns the message id 301 * @param user To who it should be sent 302 * @param body What to send 303 */ 304 QString send(const QString &user, const QString &body); 305 /** 306 * Edit sent message 307 * @param messageId Id of sent message 308 * @param newMessage Body of new message 309 */ 310 void editMessage(int messageId, const QString &newMessage); 311 /** 312 * Send a message to a given chat 313 * @param chat What chat to send it in 314 * @param body Text of that message 315 */ 316 QString sendToChat(const QString &chat, const QString &body); 317 /** 318 * Begins new call. 319 * @param userId ID of user to call (or multiple users separated by comas) 320 * @see acceptCall 321 * @see hangUp 322 * @see holdCall 323 * @see callStatus 324 * @see callError 325 */ 326 void makeCall(const QString &userId); 327 /** 328 * Accept an incoming call 329 * @param callId ID of call to accept. 330 * @see makeCall 331 * @see hangUp 332 * @see holdCall 333 * @see callStatus 334 * @see callError 335 * @see newCall 336 */ 337 void acceptCall(const QString &callId); 338 /** 339 * Hang up (finish) call in progress or deny an incoming call 340 * @param callId Which one 341 * @see makeCall 342 * @see acceptCall 343 * @see holdCall 344 * @see callStatus 345 * @see callError 346 * @see newCall 347 */ 348 void hangUp(const QString &callId); 349 /** 350 * Hold call in progress or resume holded call. That call will not finish, you just leave it for later. 351 * @param callId Which call 352 * @see makeCall 353 * @see acceptCall 354 * @see hangUp 355 * @see callStatus 356 * @see callError 357 * @see newCall 358 */ 359 void toggleHoldCall(const QString &callId); 360 /** 361 * Get the skoype out balance 362 */ 363 void getSkypeOut(); 364 /** 365 * Sets if the Skype is checked in short intervals by pings. If you turn that off, you will not know when skype exits. 366 * @param enabled Ping or not? 367 */ 368 void enablePings(bool enabled); 369 /** 370 * Sends one ping and takes actions if it can not be delivered (skype is down) 371 */ 372 void ping(); 373 /** 374 * What DBus bus is used? 375 */ 376 void setBus(int bus); 377 /** 378 * Set the launch timeout - after that launch of Skype will be considered as unsuccessful if connection can not be established 379 */ 380 void setLaunchTimeout(int seconds); 381 /** 382 * Set a command to start skype by 383 */ 384 void setSkypeCommand(const QString &command); 385 /** 386 * Sets if we wait a bit before connecting to Skype after it's start-up 387 */ 388 void setWaitConnect(int value); 389 /** 390 * This gets a topic for given chat session 391 * @param chat What chat wants that 392 */ 393 void getTopic(const QString &chat); 394 /** 395 * Invites a user to a chat 396 * @param chatId What chat 397 * @param userId What user 398 */ 399 void inviteUser(const QString &chatId, const QString &userId); 400 /** 401 * Closes/leaves a chat 402 * @param chatId What chat 403 */ 404 void leaveChat(const QString &chatId); 405 /** 406 * Removes a contact from the contact list 407 * @param contactId Id of the contact you want to remove 408 */ 409 void removeContact(const QString &contactId); 410 /** 411 * Adds a contact to the list 412 * @param contactId Id of the contact to add 413 * @param contactId 414 */ 415 void addContact(const QString &contactId); 416 /** 417 * Sets users authorization 418 * @param contactId ID of that user 419 * @param author for what is he authorized 420 */ 421 void setAuthor(const QString &contactId, AuthorType author); 422 signals: 423 /** 424 * Emitted when the skype changes to online (or says it goes online) 425 */ 426 void wentOnline(); 427 /** 428 * Emitted when the skype goes offline 429 */ 430 void wentOffline(); 431 /** 432 * Emitted when the skype goes away 433 */ 434 void wentAway(); 435 /** 436 * Emitted when the skype goes to Not awailable 437 */ 438 void wentNotAvailable(); 439 /** 440 * Emitted when the skype goes to DND mode 441 */ 442 void wentDND(); 443 /** 444 * Emitted when skype changes to skype me mode 445 */ 446 void wentSkypeMe(); 447 /** 448 * Emitted when skype becomes invisible 449 */ 450 void wentInvisible(); 451 /** 452 * Emitted when attempt to connect started 453 */ 454 void statusConnecting(); 455 /** 456 * Emitted when new user should be added to the list 457 * @param name The skype name of the user 458 * @param groupID The skype group id, where is user 459 */ 460 void newUser(const QString &name, int groupID); 461 /** 462 * All contacts should be asked to request update of their information. This is emitted after the connection to skype is made. 463 */ 464 void updateAllContacts(); 465 /** 466 * This is emitted whenever some contact should be notified of info change 467 * @param contact What contact is it 468 * @param change The change. The syntax is [property (displayname, onlinestatus..)] [value] 469 */ 470 void contactInfo(const QString &contact, const QString &change); 471 /** 472 * This is emitted when a new message is received 473 * @param user Contact ID of user that sent it. It is NOT guaranteed that the user is in list! 474 * @param body The message body that was received 475 * @param messageId ID of that message 476 * @param timeStamp time when message was send 477 */ 478 void receivedIM(const QString &user, const QString &body, const QString &messageId, const QDateTime &timeStamp); 479 /** 480 * This is emitted when a new message from multi-user chat is received 481 * @param chat Id of the chat 482 * @param body Tect of the message 483 * @param messageId Id of this message to get information about it if needed 484 * @param user Who sent it to that chat (ID) 485 * @param timeStamp time when message was send 486 */ 487 void receivedMultiIM(const QString &chat, const QString &body, const QString &messageId, const QString &user, const QDateTime &timeStamp); 488 /** 489 * This is emitted when an Id of the last outgoing message is known 490 * @param id The ID of that message 491 */ 492 void gotMessageId(const QString &id); 493 /** 494 * This slot notifies about call status (onhold, in progress, routing, finished..) 495 * @param callId WHat call is it? 496 * @param status New status of the call. 497 * @see makeCall 498 * @see acceptCall 499 * @see hangUp 500 * @see holdCall 501 * @see callError 502 * @see newCall 503 */ 504 void callStatus(const QString &callId, const QString &status); 505 /** 506 * This slot informs of error that happened to the call. It is translated error and can be directly showed to user. 507 * @param callId ID of the call that has an error. 508 * @param message The error text 509 * @see makeCall 510 * @see acceptCall 511 * @see hangUp 512 * @see holdCall 513 * @see callStatus 514 * @see newCall 515 */ 516 void callError(const QString &callId, const QString &message); 517 /** 518 * Indicates a new call is established (is being established, incoming or so). In short, there is some new call. 519 * @param callId ID of the new call 520 * @param userId ID of the other user, or list of users (if more than one) divided by spaces 521 * @see makeCall 522 * @see acceptCall 523 * @see hangUp 524 * @see holdCall] 525 * @see callStatus 526 * @see callError 527 */ 528 void newCall(const QString &callId, const QString &userId); 529 /** 530 * Skype out balance info 531 * @param balance How much does the user have 532 * @param currency And what is it that he has 533 */ 534 void skypeOutInfo(int balance, const QString ¤cy); 535 /** 536 * Tells that my name is known or changed 537 * @param name The new name 538 */ 539 void setMyselfName(const QString &name); 540 /** 541 * Some topic has to be set 542 * @param chat What chat should change its topic 543 * @param topic The new topic 544 */ 545 void setTopic(const QString &chat, const QString &topic); 546 /** 547 * This is emitted when a new user joins a chat 548 * @param chat What chat he joined 549 * @param userId ID of the new user 550 */ 551 void joinUser(const QString &chat, const QString &userId); 552 /** 553 * This is emitted when user leaves a chat 554 * @param chat What chat did he leave 555 * @param userId ID of that user 556 * @param reason Reason why he left 557 */ 558 void leftUser(const QString &chat, const QString &userd, const QString &reason); 559 /** 560 * Emitted when some message is being sent out right now 561 * @param body Text of the message 562 * @param chat Id of the chat it has been sent to 563 */ 564 void outgoingMessage(const QString &id, const QString &body, const QString &chat); 565 /** 566 * Put this call into a group, where other calls are (will be), used with conference calls 567 * @param callId Id of the call 568 * @param groupId The id of a group 569 * Note: the group should be closed when all it's calls are closed 570 */ 571 void groupCall(const QString &callId, const QString &groupId); 572 /** 573 * Emitted when we receive auth request 574 * @param contactId who send request 575 * @param info info in request 576 */ 577 void receivedAuth(const QString &contactId, const QString &info); 578 579 ///Video section 580 581 void startReceivingVideo(const QString &callId); 582 void stopReceivingVideo(const QString &callId); 583 }; 584 585 #endif 586