1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 #ifndef SEAFILE_SESSION_H
4 #define SEAFILE_SESSION_H
5 
6 #include <glib-object.h>
7 #include "cevent.h"
8 #include "job-mgr.h"
9 
10 #include "block-mgr.h"
11 #include "fs-mgr.h"
12 #include "commit-mgr.h"
13 #include "branch-mgr.h"
14 #include "repo-mgr.h"
15 #include "clone-mgr.h"
16 #include "db.h"
17 
18 #include "sync-mgr.h"
19 #include "wt-monitor.h"
20 #include "mq-mgr.h"
21 
22 #include "http-tx-mgr.h"
23 #include "filelock-mgr.h"
24 
25 
26 #define SEAFILE_TYPE_SESSION                  (seafile_session_get_type ())
27 #define SEAFILE_SESSION(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAFILE_TYPE_SESSION, SeafileSession))
28 #define SEAFILE_IS_SESSION(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAFILE_TYPE_SESSION))
29 #define SEAFILE_SESSION_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), SEAFILE_TYPE_SESSION, SeafileSessionClass))
30 #define SEAFILE_IS_SESSION_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAFILE_TYPE_SESSION))
31 #define SEAFILE_SESSION_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAFILE_TYPE_SESSION, SeafileSessionClass))
32 
33 
34 typedef struct _SeafileSession SeafileSession;
35 typedef struct _SeafileSessionClass SeafileSessionClass;
36 
37 struct event_base;
38 
39 struct _SeafileSession {
40     GObject         parent_instance;
41 
42     struct event_base   *ev_base;
43 
44     char                *client_id;
45     char                *client_name;
46 
47     char                *seaf_dir;
48     char                *tmp_file_dir;
49     char                *worktree_dir; /* the default directory for
50                                         * storing worktrees  */
51     char                *ccnet_dir;
52     sqlite3             *config_db;
53     char                *deleted_store;
54     char                *rpc_socket_path;
55 
56     uint32_t            cdc_average_block_size;
57     SeafBlockManager    *block_mgr;
58     SeafFSManager       *fs_mgr;
59     SeafCommitManager   *commit_mgr;
60     SeafBranchManager   *branch_mgr;
61     SeafRepoManager     *repo_mgr;
62     SeafCloneManager    *clone_mgr;
63     SeafSyncManager     *sync_mgr;
64     SeafWTMonitor       *wt_monitor;
65     SeafMqManager       *mq_mgr;
66 
67     CEventManager       *ev_mgr;
68     SeafJobManager     *job_mgr;
69 
70     HttpTxManager       *http_tx_mgr;
71 
72     SeafFilelockManager *filelock_mgr;
73 
74     /* Set after all components are up and running. */
75     gboolean             started;
76 
77     gboolean             sync_extra_temp_file;
78     gboolean             enable_http_sync;
79     gboolean             disable_verify_certificate;
80 
81     gboolean             disable_block_hash;
82 
83     gboolean             use_http_proxy;
84     char                *http_proxy_type;
85     char                *http_proxy_addr;
86     int                  http_proxy_port;
87     char                *http_proxy_username;
88     char                *http_proxy_password;
89 };
90 
91 struct _SeafileSessionClass
92 {
93     GObjectClass    parent_class;
94 };
95 
96 
97 extern SeafileSession *seaf;
98 
99 SeafileSession *
100 seafile_session_new(const char *seafile_dir,
101                     const char *worktree_dir,
102                     const char *config_dir);
103 void
104 seafile_session_prepare (SeafileSession *session);
105 
106 void
107 seafile_session_start (SeafileSession *session);
108 
109 char *
110 seafile_session_get_tmp_file_path (SeafileSession *session,
111                                    const char *basename,
112                                    char path[]);
113 #if 0
114 void
115 seafile_session_add_event (SeafileSession *session,
116                            const char *type,
117                            const char *first, ...);
118 #endif
119 
120 #endif /* SEAFILE_H */
121