2 * Authors : Peter Colijn <pcolijn@nit.ca>
3 * William Lachance <wlach@nit.ca>
4 * Sharvil Nanavati <s2nanava@uwaterloo.ca>
6 * Copyright 2003-2004, Net Integration Technologies, Inc.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 // this one should be included BEFORE camel shit
28 #include "wvunixsocket.h"
37 #define namespace _namespace
38 #include <camel/camel-store.h>
42 #include <camel/camel-session.h>
43 #include <camel/camel-service.h>
44 #include <camel/camel-operation.h>
49 #include "camel-exchangeit-store.h"
52 // This file was created by using camel/providers/pop3/camel-pop3-store.c
55 /* Forward declarations */
56 static void camel_exchangeit_store_class_init(CamelExchangeITStoreClass
*camel_exchangeit_store_class
);
57 static void camel_exchangeit_store_init(CamelExchangeITStore
*store
,
59 static void camel_exchangeit_store_finalize(CamelObject
*object
);
61 /* Forward declarations of "member functions" */
62 static gboolean
exchangeit_connect(CamelService
*service
,
64 static gboolean
exchangeit_disconnect(CamelService
*service
,
68 /* For internal use only, to communicate with shell */
69 static WvStream
*stream
= NULL
;
71 /* Called when a new connection should be established with the server with the
72 * given service (send/receive clicked or a scheduled send/receive is run)
73 * But we just use it to update the progress bar in a super cheesey way by
74 * reading progress across a pipe from our shell component :)
76 static gboolean
exchangeit_connect(CamelService
*service
, CamelException
*ex
)
78 WvString
socket_name("%s/.evolution-exchangeit/pipehack",
80 stream
= new WvUnixConn(socket_name
);
81 uint32_t start_cmd
= 1;
85 g_warning("******** Connection not accepted!");
88 if (sizeof(uint32_t) != stream
->write(&start_cmd
, sizeof(start_cmd
)))
90 g_warning("******** Unable to write start_cmd!");
94 while (stream
->isok())
98 if (sizeof(uint32_t) == stream
->read(&progress
, sizeof(uint32_t)))
100 if (progress
> 0 && progress
<= 100)
102 if (camel_operation_cancel_check (NULL
))
104 // Try to tell the shell to stop sending stuff
107 uint32_t end_cmd
= 0;
108 stream
->write(&end_cmd
, sizeof(uint32_t));
111 camel_operation_cancel(NULL
);
115 camel_operation_start(NULL
, _("Syncing..."));
116 camel_operation_progress(NULL
, progress
);
120 g_warning("******** Received failure message from shell!");
121 // FIXME: pop up an error instead of saying we're complete
122 // in this case (maybe not here though, maybe send a message
123 // back to the shell? pcolijn)
132 camel_operation_end(NULL
);
133 WvStream
*tmp_stream
= stream
;
135 WVRELEASE(tmp_stream
);
137 // Returning FALSE lets us get called again
141 /* Called when a disconnect should occur */
142 static gboolean
exchangeit_disconnect(CamelService
*service
,
149 /* Class constructor */
150 static void camel_exchangeit_store_class_init(CamelExchangeITStoreClass
*camel_exchangeit_store_class
)
152 CamelServiceClass
*service
=
153 CAMEL_SERVICE_CLASS(camel_exchangeit_store_class
);
155 /* Overload virtual methods */
156 service
->connect
= exchangeit_connect
;
157 service
->disconnect
= exchangeit_disconnect
;
161 static void camel_exchangeit_store_init(CamelExchangeITStore
*store
,
166 /* Registers a new class with Camel and returns the type */
167 CamelType
camel_exchangeit_store_get_type()
169 static CamelType camel_exchangeit_store_type
= CAMEL_INVALID_TYPE
;
171 if (!camel_exchangeit_store_type
)
173 camel_exchangeit_store_type
=
174 camel_type_register(CAMEL_STORE_TYPE
,
175 "CamelExchangeITStore",
176 sizeof(CamelExchangeITStore
),
177 sizeof(CamelExchangeITStoreClass
),
178 (CamelObjectClassInitFunc
)camel_exchangeit_store_class_init
,
180 (CamelObjectInitFunc
)camel_exchangeit_store_init
,
181 camel_exchangeit_store_finalize
);
183 return camel_exchangeit_store_type
;
187 static void camel_exchangeit_store_finalize(CamelObject
*object
)