~ubuntu-branches/ubuntu/utopic/libinfinity/utopic-proposed

« back to all changes in this revision

Viewing changes to infinoted/infinoted-directory-sync.c

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Kern
  • Date: 2011-04-01 10:44:57 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110401104457-q7927ly61fr51tqs
Tags: 0.5.0-1
* New upstream release.
* Drop patches applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* libinfinity - a GObject-based infinote implementation
2
 
 * Copyright (C) 2007, 2008, 2009 Armin Burgmeier <armin@arbur.net>
 
2
 * Copyright (C) 2007-2011 Armin Burgmeier <armin@arbur.net>
3
3
 *
4
4
 * This library is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU Lesser General Public
33
33
  InfinotedDirectorySync* dsync;
34
34
  InfdDirectoryIter iter;
35
35
  InfdSessionProxy* proxy;
36
 
  gpointer timeout_handle;
 
36
  InfIoTimeout* timeout;
37
37
 
38
38
  gchar* path;
39
39
};
81
81
  InfIo* io;
82
82
  io = infd_directory_get_io(dsync->directory);
83
83
 
84
 
  g_assert(session->timeout_handle == NULL);
 
84
  g_assert(session->timeout == NULL);
85
85
 
86
 
  session->timeout_handle = inf_io_add_timeout(
 
86
  session->timeout = inf_io_add_timeout(
87
87
    io,
88
88
    dsync->sync_interval * 1000,
89
89
    infinoted_directory_sync_session_timeout_cb,
99
99
  InfIo* io;
100
100
  io = infd_directory_get_io(dsync->directory);
101
101
 
102
 
  g_assert(session->timeout_handle != NULL);
103
 
 
104
 
  inf_io_remove_timeout(io, session->timeout_handle);
105
 
  session->timeout_handle = NULL;
106
 
}
107
 
 
108
 
static void
109
 
infinoted_directory_sync_buffer_insert_text_cb(InfTextBuffer* buffer,
 
102
  g_assert(session->timeout != NULL);
 
103
 
 
104
  inf_io_remove_timeout(io, session->timeout);
 
105
  session->timeout = NULL;
 
106
}
 
107
 
 
108
static void
 
109
infinoted_directory_sync_buffer_text_inserted_cb(InfTextBuffer* buffer,
 
110
                                                 guint position,
 
111
                                                 InfTextChunk* text,
 
112
                                                 InfUser* user,
 
113
                                                 gpointer user_data)
 
114
{
 
115
  InfinotedDirectorySyncSession* session;
 
116
  session = (InfinotedDirectorySyncSession*)user_data;
 
117
 
 
118
  if(session->timeout == NULL)
 
119
    infinoted_directory_sync_session_start(session->dsync, session);
 
120
}
 
121
 
 
122
static void
 
123
infinoted_directory_sync_buffer_text_erased_cb(InfTextBuffer* buffer,
110
124
                                               guint position,
111
125
                                               InfTextChunk* text,
112
126
                                               InfUser* user,
115
129
  InfinotedDirectorySyncSession* session;
116
130
  session = (InfinotedDirectorySyncSession*)user_data;
117
131
 
118
 
  if(session->timeout_handle == NULL)
119
 
    infinoted_directory_sync_session_start(session->dsync, session);
120
 
}
121
 
 
122
 
static void
123
 
infinoted_directory_sync_buffer_erase_text_cb(InfTextBuffer* buffer,
124
 
                                              guint position,
125
 
                                              InfTextChunk* text,
126
 
                                              InfUser* user,
127
 
                                              gpointer user_data)
128
 
{
129
 
  InfinotedDirectorySyncSession* session;
130
 
  session = (InfinotedDirectorySyncSession*)user_data;
131
 
 
132
 
  if(session->timeout_handle == NULL)
 
132
  if(session->timeout == NULL)
133
133
    infinoted_directory_sync_session_start(session->dsync, session);
134
134
}
135
135
 
147
147
  iter = &session->iter;
148
148
  error = NULL;
149
149
 
150
 
  if(session->timeout_handle != NULL)
 
150
  if(session->timeout != NULL)
151
151
  {
152
152
    inf_io_remove_timeout(
153
153
      infd_directory_get_io(dsync->directory),
154
 
      session->timeout_handle
 
154
      session->timeout
155
155
    );
156
156
 
157
 
    session->timeout_handle = NULL;
 
157
    session->timeout = NULL;
158
158
  }
159
159
 
160
160
  buffer = inf_session_get_buffer(
203
203
  InfinotedDirectorySyncSession* session;
204
204
 
205
205
  session = (InfinotedDirectorySyncSession*)user_data;
206
 
  session->timeout_handle = NULL;
 
206
  session->timeout = NULL;
207
207
 
208
208
  infinoted_directory_sync_session_save(session->dsync, session);
209
209
}
268
268
  session->iter = *iter;
269
269
 
270
270
  session->proxy = proxy;
271
 
  session->timeout_handle = NULL;
 
271
  session->timeout = NULL;
272
272
  session->path = converted;
273
273
 
274
274
  dsync->sessions = g_slist_prepend(dsync->sessions, session);
275
275
 
276
276
  buffer = inf_session_get_buffer(infd_session_proxy_get_session(proxy));
277
277
 
278
 
  g_signal_connect_after(
 
278
  g_signal_connect(
279
279
    G_OBJECT(buffer),
280
 
    "insert-text",
281
 
    G_CALLBACK(infinoted_directory_sync_buffer_insert_text_cb),
 
280
    "text-inserted",
 
281
    G_CALLBACK(infinoted_directory_sync_buffer_text_inserted_cb),
282
282
    session
283
283
  );
284
284
 
285
 
  g_signal_connect_after(
 
285
  g_signal_connect(
286
286
    G_OBJECT(buffer),
287
 
    "erase-text",
288
 
    G_CALLBACK(infinoted_directory_sync_buffer_erase_text_cb),
 
287
    "text-erased",
 
288
    G_CALLBACK(infinoted_directory_sync_buffer_text_erased_cb),
289
289
    session
290
290
  );
291
291
 
299
299
{
300
300
  InfTextBuffer* buffer;
301
301
 
302
 
  if(sess->timeout_handle != NULL)
 
302
  if(sess->timeout != NULL)
303
303
  {
304
304
    infinoted_directory_sync_session_save(dsync, sess);
305
305
    infinoted_directory_sync_session_stop(dsync, sess);
311
311
 
312
312
  inf_signal_handlers_disconnect_by_func(
313
313
    G_OBJECT(buffer),
314
 
    G_CALLBACK(infinoted_directory_sync_buffer_insert_text_cb),
 
314
    G_CALLBACK(infinoted_directory_sync_buffer_text_inserted_cb),
315
315
    sess
316
316
  );
317
317
 
318
318
  inf_signal_handlers_disconnect_by_func(
319
319
    G_OBJECT(buffer),
320
 
    G_CALLBACK(infinoted_directory_sync_buffer_erase_text_cb),
 
320
    G_CALLBACK(infinoted_directory_sync_buffer_text_erased_cb),
321
321
    sess
322
322
  );
323
323