1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Authors : Patrick Patterson <ppatters@nit.ca>
4 * Peter Colijn <pcolijn@nit.ca>
5 * Scott MacLean <scott@nit.ca>
6 * William Lachance <wlach@nit.ca>
8 * Copyright 2003-2004, Net Integration Technologies, Inc.
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 #include "exchangeitadaptor.h"
28 #include "exchangeitstorage.h"
29 #include "eituniconfkeys.h"
31 bool Sync::apply_response(WvStringList
&parts
,
33 ExchangeItStorage
*storage
)
37 log(WvLog::Debug1
, "Malformed response: no response!!\n");
41 WvString response
= parts
.popstr();
43 if (response
== "NOFOLDER")
45 if (!adaptor
|| !adaptor
->get_key())
48 log(WvLog::Debug1
, "Got %s, removing %s\n",
49 response
, adaptor
->get_key());
51 // remove the folder if it doesn't exist on the server, but we
52 // think it does? this is what ExchangeItOutlook does..
53 UniConf folders
= storage
->get_state()[FOLDERS_KEY
];
54 folders
[TODELETE_KEY
][adaptor
->get_key()].setmeint(1);
56 // this isn't technically a problem; we have successfully applied
60 else if (response
== "BADFOLDER")
62 // BADFOLDER usually means we tried to sync an email folder,
63 // which does nothing right now
64 log(WvLog::Debug1
, "Got %s, ignoring\n", response
);
70 log(WvLog::Debug1
, "Got %s, expected OK\n", response
);
76 log(WvLog::Debug1
, "Malformed response: too few parameters!\n");
80 WvString version
= parts
.popstr();
81 uint32_t new_version
= version
.num();
83 if (new_version
< adaptor
->get_version())
85 "Adaptor claims it has a later version (%s vs. %s) "
86 "than what's on the server!\n",
87 adaptor
->get_version(), new_version
);
89 adaptor
->set_version(new_version
);
93 void Sync::get_command(WvString
&command
,
102 params
.append(new WvString(adaptor
->get_version()), true);
103 params
.append(new WvString(url_encode(adaptor
->key
)), true);
104 params
.append(new WvString(adaptor
->get_type()), true);
108 bool SyncFolders::check_error(const string
&response
, const Strings
¶ms
)
110 if (response
!= "ERROR")
114 for (Strings::const_iterator i
= params
.begin(); i
!= params
.end(); ++i
)
118 set_error("Unknown server error");
121 error
.erase(error
.size() - 1);