Welcome to mirror list, hosted at ThFree Co, Russian Federation.

socketapi.h « mirall « src - github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2f3446ee82dbaaa7f69db9e4eb26931b5b82c2a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * Copyright (C) by Dominik Schmidt <dev@dominik-schmidt.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 */


#ifndef SOCKETAPI_H
#define SOCKETAPI_H

extern "C" {
#include <std/c_string.h>
}

#include <sqlite3.h>

#include <QWeakPointer>
#include <QTcpSocket>
#include <QTcpServer>
#include <QLocalServer>

#include "mirall/syncfileitem.h"
#include "mirall/syncjournalfilerecord.h"
#include "mirall/ownsql.h"

class QUrl;
class QLocalSocket;
class QStringList;

namespace Mirall {

typedef QLocalSocket SocketType;

class SyncFileStatus;
class Folder;

class SocketApi : public QObject
{
Q_OBJECT

public:
    SocketApi(QObject* parent);
    virtual ~SocketApi();

public slots:
    void slotUpdateFolderView(const QString&);
    void slotUnregisterPath( const QString& alias );
    void slotRegisterPath( const QString& alias );
    void slotReadExcludes();
    void slotClearExcludesList();
private slots:
    void slotNewConnection();
    void onLostConnection();
    void slotReadSocket();
    void slotJobCompleted(const QString &, const SyncFileItem &);
    void slotSyncItemDiscovered(const QString &, const SyncFileItem &);

private:
    SyncFileStatus fileStatus(Folder *folder, const QString& systemFileName, c_strlist_t *excludes );
    SyncJournalFileRecord dbFileRecord_capi( Folder *folder, QString fileName );
    SyncFileStatus recursiveFolderStatus(Folder *folder, const QString& fileName, c_strlist_t *excludes  );
    SqlQuery *getSqlQuery( Folder *folder );

    void sendMessage(SocketType* socket, const QString& message, bool doWait = false);
    void broadcastMessage(const QString& verb, const QString &path, const QString &status = QString::null, bool doWait = false);

    Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString& argument, SocketType* socket);
    Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString& argument, SocketType* socket);

    Q_INVOKABLE void command_VERSION(const QString& argument, SocketType* socket);

#ifdef SOCKETAPI_TCP
    QTcpServer _localServer;
#else
    QLocalServer _localServer;
#endif
    QList<SocketType*> _listeners;
    c_strlist_t *_excludes;
    QHash<Folder*, SqlQuery*> _dbQueries;
    QHash<Folder*, SqlDatabase*> _openDbs;
};

}
#endif // SOCKETAPI_H