aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/barrier/DragInformation.h
blob: a5d76b0c457b2a2f13d1c7cb2bd783b71a1cd3b8 (plain) (blame)
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
/*
 * barrier -- mouse and keyboard sharing utility
 * Copyright (C) 2013-2016 Symless Ltd.
 *
 * This package is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * found in the file LICENSE that should have accompanied this file.
 *
 * This package 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "common/stdvector.h"
#include "base/String.h"
#include "base/EventTypes.h"

class DragInformation;
typedef std::vector<DragInformation> DragFileList;

class DragInformation {
public:
    DragInformation();
    ~DragInformation() { }

    String&            getFilename() { return m_filename; }
    void                setFilename(String& name) { m_filename = name; }
    size_t                getFilesize() { return m_filesize; }
    void                setFilesize(size_t size) { m_filesize = size; }

    static void            parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, String data);
    static String        getDragFileExtension(String filename);
    // helper function to setup drag info
    // example: filename1,filesize1,filename2,filesize2,
    // return file count
    static int            setupDragInfo(DragFileList& fileList, String& output);

    static bool            isFileValid(String filename);

private:
    static size_t        stringToNum(String& str);
    static String        getFileSize(String& filename);

private:
    String                m_filename;
    size_t                m_filesize;
};