summaryrefslogtreecommitdiff
path: root/src/dropbox-command-client.h
blob: 1c1b2792c78bcef18c7ef0d1b768f06d571ff794 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * Copyright 2008 Evenflow, Inc.
 *
 * dropbox-command-client.h
 * Header file for caja-dropbox-command.c
 *
 * This file is part of caja-dropbox.
 *
 * caja-dropbox 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 3 of the License, or
 * (at your option) any later version.
 *
 * caja-dropbox 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 caja-dropbox.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef DROPBOX_COMMAND_CLIENT_H
#define DROPBOX_COMMAND_CLIENT_H

#include <libcaja-extension/caja-info-provider.h>
#include <libcaja-extension/caja-file-info.h>

G_BEGIN_DECLS

/* command structs */
typedef enum {GET_FILE_INFO, GENERAL_COMMAND} CajaDropboxRequestType;

typedef struct {
  CajaDropboxRequestType request_type;
} DropboxCommand;

typedef struct {
  DropboxCommand dc;
  CajaInfoProvider *provider;
  GClosure *update_complete;
  CajaFileInfo *file;
  gboolean cancelled;
} DropboxFileInfoCommand;

typedef struct {
  DropboxFileInfoCommand *dfic;
  GHashTable *file_status_response;
  GHashTable *folder_tag_response;
  GHashTable *emblems_response;
} DropboxFileInfoCommandResponse;

typedef void (*CajaDropboxCommandResponseHandler)(GHashTable *, gpointer);

typedef struct {
  DropboxCommand dc;
  gchar *command_name;
  GHashTable *command_args;
  CajaDropboxCommandResponseHandler handler;
  gpointer handler_ud;
} DropboxGeneralCommand;

typedef void (*DropboxCommandClientConnectionAttemptHook)(guint, gpointer);
typedef GHookFunc DropboxCommandClientConnectHook;

typedef struct {
  GMutex *command_connected_mutex;
  gboolean command_connected;
  GAsyncQueue *command_queue;
  GList *ca_hooklist;
  GHookList onconnect_hooklist;
  GHookList ondisconnect_hooklist;
} DropboxCommandClient;

gboolean dropbox_command_client_is_connected(DropboxCommandClient *dcc);

void dropbox_command_client_force_reconnect(DropboxCommandClient *dcc);

void
dropbox_command_client_request(DropboxCommandClient *dcc, DropboxCommand *dc);

void
dropbox_command_client_setup(DropboxCommandClient *dcc);

void
dropbox_command_client_start(DropboxCommandClient *dcc);

void dropbox_command_client_send_simple_command(DropboxCommandClient *dcc,
						const char *command);

void dropbox_command_client_send_command(DropboxCommandClient *dcc,
					 CajaDropboxCommandResponseHandler h,
					 gpointer ud,
					 const char *command, ...);
void
dropbox_command_client_add_on_connect_hook(DropboxCommandClient *dcc,
					   DropboxCommandClientConnectHook dhcch,
					   gpointer ud);

void
dropbox_command_client_add_on_disconnect_hook(DropboxCommandClient *dcc,
					      DropboxCommandClientConnectHook dhcch,
					      gpointer ud);

void
dropbox_command_client_add_connection_attempt_hook(DropboxCommandClient *dcc,
						   DropboxCommandClientConnectionAttemptHook dhcch,
						   gpointer ud);

G_END_DECLS

#endif