root / modules / file_transfer / file_transfer_notifications.cpp @ 18636b4a
History | View | Annotate | Download (2 kB)
| 1 | /***************************************************************************
|
|---|---|
| 2 | * * |
| 3 | * This program is free software; you can redistribute it and/or modify * |
| 4 | * it under the terms of the GNU General Public License as published by * |
| 5 | * the Free Software Foundation; either version 2 of the License, or * |
| 6 | * (at your option) any later version. * |
| 7 | * * |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | #include <fcntl.h> |
| 11 | |
| 12 | #include "debug.h" |
| 13 | #include "file_transfer.h" |
| 14 | #include "file_transfer_manager.h" |
| 15 | #include "message_box.h" |
| 16 | #include "misc/misc.h" |
| 17 | |
| 18 | #include "file_transfer_notifications.h" |
| 19 | |
| 20 | NewFileTransferNotification::NewFileTransferNotification(FileTransfer *ft, DccSocket *socket, const UserListElements &userListElements,
|
| 21 | FileTransfer::StartType startType) |
| 22 | : Notification("FileTransfer/IncomingFile", "SendFile", userListElements), ft(ft), socket(socket), fileName("") |
| 23 | {
|
| 24 | if (startType == FileTransfer::StartRestore)
|
| 25 | {
|
| 26 | addCallback(tr("Continue"), SLOT(callbackAccept()));
|
| 27 | addCallback(tr("Save file under new name"), SLOT(callbackAcceptAsNew()));
|
| 28 | addCallback(tr("Ignore transfer"), SLOT(callbackDiscard()));
|
| 29 | |
| 30 | Continue = true;
|
| 31 | } |
| 32 | else
|
| 33 | {
|
| 34 | addCallback(tr("Accept"), SLOT(callbackAccept()));
|
| 35 | addCallback(tr("Reject"), SLOT(callbackReject()));
|
| 36 | |
| 37 | Continue = false;
|
| 38 | } |
| 39 | |
| 40 | setDefaultCallback(30 * 60 * 1000, SLOT(callbackDiscard())); |
| 41 | } |
| 42 | |
| 43 | void NewFileTransferNotification::callbackAccept()
|
| 44 | {
|
| 45 | kdebugf(); |
| 46 | |
| 47 | if (Continue)
|
| 48 | file_transfer_manager->acceptFile(ft, socket, ft->fileName(), true);
|
| 49 | else
|
| 50 | file_transfer_manager->acceptFile(ft, socket, QString::null); |
| 51 | close(); |
| 52 | } |
| 53 | |
| 54 | void NewFileTransferNotification::callbackAcceptAsNew()
|
| 55 | {
|
| 56 | kdebugf(); |
| 57 | |
| 58 | file_transfer_manager->acceptFile(ft, socket, QString::null); |
| 59 | close(); |
| 60 | } |
| 61 | |
| 62 | void NewFileTransferNotification::callbackReject()
|
| 63 | {
|
| 64 | kdebugf(); |
| 65 | |
| 66 | file_transfer_manager->rejectFile(socket); |
| 67 | close(); |
| 68 | } |