source: qutecom-coip/libs/coipmanager/plugins/filesessionmanager/purple/PurpleReceiveFileSession.cpp @ 175:f8f833429b88

Last change on this file since 175:f8f833429b88 was 175:f8f833429b88, checked in by laurent, 3 years ago

fix potential crash

File size: 2.7 KB
Line 
1/*
2 * QuteCom, a voice over Internet phone
3 * Copyright (C) 2010 Mbdsys
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20#include "PurpleReceiveFileSession.h"
21
22#include <coipmanager/CoIpManager.h>
23#include <coipmanager/datamanager/UserProfileManager.h>
24
25#include <util/File.h>
26#include <util/Logger.h>
27#include <util/SafeConnect.h>
28
29PurpleReceiveFileSession::PurpleReceiveFileSession(CoIpManager & coIpManager)
30        : IReceiveFileSessionPlugin(coIpManager) {
31}
32
33PurpleReceiveFileSession::PurpleReceiveFileSession(const PurpleReceiveFileSession & PurpleReceiveFileSession)
34        : IReceiveFileSessionPlugin(PurpleReceiveFileSession) {
35
36        _fileName = PurpleReceiveFileSession._fileName;
37        _fileSize = PurpleReceiveFileSession._fileSize;
38}
39
40Identifiable * PurpleReceiveFileSession::clone() const {
41        return new PurpleReceiveFileSession(*this);
42}
43
44PurpleReceiveFileSession::~PurpleReceiveFileSession() {
45        _xfer->ui_data = 0;
46}
47
48void PurpleReceiveFileSession::start() {
49        LOG_DEBUG("starting file transfer");
50        //Only start the file transfer if it's still not marked as cancelled and therefore can be begun.
51        if ((purple_xfer_get_status(_xfer) != PURPLE_XFER_STATUS_CANCEL_LOCAL) &&
52                (purple_xfer_get_status(_xfer) != PURPLE_XFER_STATUS_CANCEL_REMOTE)) {
53                //XXX should do further error checking as done by purple_xfer_choose_file_ok_cb() in purple's ft.c
54                std::string path = _filePath +  _fileName;
55                purple_xfer_request_accepted(_xfer, path.c_str());
56        }
57}
58
59void PurpleReceiveFileSession::pause() {
60        LOG_DEBUG("pausing file transfer");
61}
62
63void PurpleReceiveFileSession::resume() {
64        LOG_DEBUG("resuming file transfer");
65}
66
67void PurpleReceiveFileSession::stop() {
68       
69        LOG_DEBUG("stopping file transfer");
70       
71        purple_xfer_request_denied(_xfer);
72       
73        if ((purple_xfer_get_status(_xfer) == PURPLE_XFER_STATUS_UNKNOWN) ||
74                (purple_xfer_get_status(_xfer) == PURPLE_XFER_STATUS_NOT_STARTED) ||
75                (purple_xfer_get_status(_xfer) == PURPLE_XFER_STATUS_STARTED) ||
76                (purple_xfer_get_status(_xfer) == PURPLE_XFER_STATUS_ACCEPTED)) {
77                purple_xfer_cancel_local(_xfer);
78        }
79       
80}
Note: See TracBrowser for help on using the repository browser.