~mateo-salta/nitroshare/nitroshare

« back to all changes in this revision

Viewing changes to src/file/CFileReceiver.cpp

  • Committer: Nathan Osman
  • Date: 2012-07-03 22:45:37 UTC
  • Revision ID: admin@quickmediasolutions.com-20120703224537-ymuk5duhpzg4b63p
Made some more minor tweaks to the code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
16
 
17
17
#include <QDebug>
18
 
#include <QDir>
19
18
#include <QFile>
20
 
#include <QFileInfo>
21
19
#include <QHostAddress>
22
20
#include <QRegExp>
23
 
#include <QVariantMap>
24
21
#include <qjson/qobjecthelper.h>
25
22
 
26
23
#include <dialogs/CAcceptPromptDialog.h>
52
49
 
53
50
    /* If we're waiting for the headers then parse them. */
54
51
    if(m_state == WaitingForHeader)
55
 
    {
56
 
        QVariantMap map = DecodeJSON(data);
57
 
        ParseHeaders(map);
58
 
    }
 
52
        ParseHeaders(DecodeJSON(data));
59
53
    else
60
54
    {
61
55
        /* If there are files remaining to be read, then read the next one. */
69
63
            SendStatus("continue");
70
64
        }
71
65
 
72
 
        /* If we have read all of the files, send the ACK back to the server. */
 
66
        /* If we have read all of the files, close the connection. */
73
67
        if(!m_headers.size())
74
68
        {
75
69
            /* Let the user know we received everything and close
94
88
    }
95
89
 
96
90
    /* Construct the headers for each of the files. */
97
 
    m_hostname = map["name"].toString();
 
91
    m_client_name = map["name"].toString();
98
92
    foreach(QVariant variant, map["files"].toList())
99
93
    {
100
94
        CFileHeader * header = new CFileHeader;
132
126
 
133
127
    /* Perhaps the policy is to prompt the user? If so, do it. */
134
128
    if(policy == Defaults::AcceptPrompt)
135
 
    {
136
 
        CAcceptPromptDialog dialog(m_hostname, m_headers);
137
 
        return dialog.exec();
138
 
    }
 
129
        return CAcceptPromptDialog(m_client_name, m_headers).exec();
139
130
 
140
131
    /* Note: we don't perform the RegEx match until we are actually
141
132
       ready to perform the transfer since we still need the headers
232
223
    ++m_files_received;
233
224
 
234
225
    /* ...and we're done with this file. */
235
 
    qDebug() << "File stored on the local filesysten.";
 
226
    qDebug() << "File stored on the local filesystem.";
236
227
}