/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Colin Leroy <colin@colino.net> and
+ * Copyright (C) 1999-2015 Colin Leroy <colin@colino.net> and
* the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include "procheader.h"
#include "folder.h"
#include "folderview.h"
+#include "folder_item_prefs.h"
#include "vcalendar.h"
#include "vcal_folder.h"
#include "vcal_prefs.h"
#include "mainwindow.h"
#include "statusbar.h"
#include "msgcache.h"
+#include "passwordstore.h"
#include "timing.h"
#include "messageview.h"
{
N_("_New meeting..."),
N_("_Export calendar..."),
- N_("_Subscribe to webCal..."),
+ N_("_Subscribe to Webcal..."),
N_("_Unsubscribe..."),
N_("_Rename..."),
N_("U_pdate subscriptions"),
prop = icalcomponent_get_first_property(evt, ICAL_DTSTART_PROPERTY);
if (prop) {
ritr = icalrecur_iterator_new(recur, icalproperty_get_dtstart(prop));
- next = icalrecur_iterator_next(ritr); /* skip first one */
+ next = icalrecur_iterator_next(ritr); /* skip first one */
}
rprop = rprop2;
item->evtlist = g_slist_prepend(item->evtlist, data);
data = NULL;
}
- if (rprop) {
+ if (rprop && ritr) {
struct icaldurationtype ical_dur;
struct icaltimetype dtstart, dtend;
evt = icalcomponent_new_clone(evt);
if (prop)
dtend = icalproperty_get_dtend(prop);
ical_dur = icaltime_subtract(dtend, dtstart);
- next = icalrecur_iterator_next(ritr);
+ next = icalrecur_iterator_next(ritr);
if (!icaltime_is_null_time(next) &&
!icaltime_is_null_time(dtstart) && i < 100) {
prop = icalcomponent_get_first_property(evt, ICAL_DTSTART_PROPERTY);
GSList *vcal_get_events_list(FolderItem *item)
{
- DIR *dp;
- struct dirent *d;
+ GDir *dp;
+ const gchar *d;
GSList *events = NULL;
+ GError *error = NULL;
if (item != item->folder->inbox) {
GSList *subs = vcal_folder_get_webcal_events_for_folder(item);
return events;
}
- dp = opendir(vcal_manager_get_event_path());
+ dp = g_dir_open(vcal_manager_get_event_path(), 0, &error);
if (!dp) {
- FILE_OP_ERROR(vcal_manager_get_event_path(), "opendir");
+ debug_print("couldn't open dir '%s': %s (%d)\n",
+ vcal_manager_get_event_path(), error->message, error->code);
+ g_error_free(error);
return 0;
}
- while ((d = readdir(dp)) != NULL) {
+ while ((d = g_dir_read_name(dp)) != NULL) {
VCalEvent *event = NULL;
- if (d->d_name[0] == '.' || strstr(d->d_name, ".bak")
- || !strcmp(d->d_name, "internal.ics")
- || !strcmp(d->d_name, "internal.ifb")
- || !strcmp(d->d_name, "multisync"))
+ if (d[0] == '.' || strstr(d, ".bak")
+ || !strcmp(d, "internal.ics")
+ || !strcmp(d, "internal.ifb")
+ || !strcmp(d, "multisync"))
continue;
- event = vcal_manager_load_event(d->d_name);
+ event = vcal_manager_load_event(d);
if (!event)
continue;
- if (event->rec_occurence) {
+ if (event->rec_occurrence) {
vcal_manager_free_event(event);
- claws_unlink(d->d_name);
+ claws_unlink(d);
continue;
}
struct icaldurationtype ical_dur;
int i = 0;
- debug_print("dumping recurring events from main event %s\n", d->d_name);
+ debug_print("dumping recurring events from main event %s\n", d);
recur = icalrecurrencetype_from_string(event->recur);
dtstart = icaltime_from_string(event->dtstart);
event->sequence, event->type);
g_free(uid);
vcal_manager_copy_attendees(event, nevent);
- nevent->rec_occurence = TRUE;
+ nevent->rec_occurrence = TRUE;
vcal_manager_save_event(nevent, FALSE);
account = vcal_manager_get_account_from_event(event);
status =
vcal_manager_free_event(event);
}
}
- closedir(dp);
+ g_dir_close(dp);
return g_slist_reverse(events);
}
continue;
g_hash_table_insert(hash_uids, GINT_TO_POINTER(n_msg), g_strdup(event->uid));
- if (event->rec_occurence) {
+ if (event->rec_occurrence) {
vcal_manager_free_event(event);
continue;
}
if (_item == folder->inbox)
vcal_remove_event(folder, msginfo);
- procmsg_msginfo_free(msginfo);
+ procmsg_msginfo_free(&msginfo);
return 0;
}
static gboolean vcal_scan_required(Folder *folder, FolderItem *item)
{
- struct stat s;
+ GStatBuf s;
VCalFolderItem *vitem = (VCalFolderItem *)item;
g_return_val_if_fail(item != NULL, FALSE);
static void vcal_set_mtime(Folder *folder, FolderItem *item)
{
- struct stat s;
+ GStatBuf s;
gchar *path = folder_item_get_path(item);
if (folder->inbox != item)
}
item->mtime = s.st_mtime;
- debug_print("VCAL: forced mtime of %s to %ld\n", item->name?item->name:"(null)", item->mtime);
+ debug_print("VCAL: forced mtime of %s to %lld\n",
+ item->name?item->name:"(null)", (long long)item->mtime);
g_free(path);
}
{
FolderItem *item = folder?folder->inbox:NULL;
gboolean need_scan = folder?vcal_scan_required(folder, item):TRUE;
+ gchar *export_pass = NULL;
+ gchar *export_freebusy_pass = NULL;
if (vcal_folder_lock_count) /* blocked */
return;
vcal_folder_lock_count++;
+
+ export_pass = vcal_passwd_get("export");
+ export_freebusy_pass = vcal_passwd_get("export_freebusy");
+
if (vcal_meeting_export_calendar(vcalprefs.export_path,
vcalprefs.export_user,
- vcalprefs.export_pass,
+ export_pass,
TRUE)) {
debug_print("exporting calendar\n");
if (vcalprefs.export_enable &&
vcalprefs.export_command &&
strlen(vcalprefs.export_command))
execute_command_line(
- vcalprefs.export_command, TRUE);
+ vcalprefs.export_command, TRUE, NULL);
}
+ if (export_pass != NULL) {
+ memset(export_pass, 0, strlen(export_pass));
+ }
+ g_free(export_pass);
if (vcal_meeting_export_freebusy(vcalprefs.export_freebusy_path,
vcalprefs.export_freebusy_user,
- vcalprefs.export_freebusy_pass)) {
+ export_freebusy_pass)) {
debug_print("exporting freebusy\n");
if (vcalprefs.export_freebusy_enable &&
vcalprefs.export_freebusy_command &&
strlen(vcalprefs.export_freebusy_command))
execute_command_line(
- vcalprefs.export_freebusy_command, TRUE);
+ vcalprefs.export_freebusy_command, TRUE, NULL);
+ }
+ if (export_freebusy_pass != NULL) {
+ memset(export_freebusy_pass, 0, strlen(export_freebusy_pass));
}
+ g_free(export_freebusy_pass);
vcal_folder_lock_count--;
if (!need_scan && folder) {
vcal_set_mtime(folder, folder->inbox);
curl_easy_setopt(curl_ctx, CURLOPT_TIMEOUT, prefs_common_get_prefs()->io_timeout_secs);
curl_easy_setopt(curl_ctx, CURLOPT_NOSIGNAL, 1);
#if LIBCURL_VERSION_NUM >= 0x070a00
- curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0);
- curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYHOST, 0);
+ if(vcalprefs.ssl_verify_peer == FALSE) {
+ curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYHOST, 0);
+ }
#endif
curl_easy_setopt(curl_ctx, CURLOPT_USERAGENT,
"Claws Mail vCalendar plugin "
pthread_attr_t pta;
#endif
void *res;
- gboolean killed;
gchar *error = NULL;
result = NULL;
td = g_new0(thread_data, 1);
res = NULL;
- killed = FALSE;
td->url = url;
td->result = NULL;
curl_easy_setopt(curl_ctx, CURLOPT_READDATA, fp);
curl_easy_setopt(curl_ctx, CURLOPT_HTTPHEADER, headers);
#if LIBCURL_VERSION_NUM >= 0x070a00
- curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0);
- curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYHOST, 0);
+ if(vcalprefs.ssl_verify_peer == FALSE) {
+ curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYHOST, 0);
+ }
#endif
curl_easy_setopt(curl_ctx, CURLOPT_USERAGENT,
"Claws Mail vCalendar plugin "
- "(http://www.claws-mail.org/plugins.php)");
+ "(" PLUGINS_URI ")");
curl_easy_setopt(curl_ctx, CURLOPT_INFILESIZE, filesize);
res = curl_easy_perform(curl_ctx);
g_free(userpwd);
curl_easy_getinfo(curl_ctx, CURLINFO_RESPONSE_CODE, &response_code);
if (response_code < 200 || response_code >= 300) {
- g_warning("Can't export calendar, got code %ld\n", response_code);
+ g_warning("Can't export calendar, got code %ld", response_code);
res = FALSE;
}
curl_easy_cleanup(curl_ctx);
icalcomponent *cal = NULL;
if (root == NULL) {
- g_warning("can't get root folder\n");
+ g_warning("can't get root folder");
g_free(feed);
if (error)
g_free(error);
}
if (strncmp(feed, "BEGIN:VCALENDAR", strlen("BEGIN:VCALENDAR"))) {
if (verbose && manual_update) {
- alertpanel_error(_("This URL does not look like a WebCal URL:\n%s\n%s"),
+ alertpanel_error(_("This URL does not look like a Webcal URL:\n%s\n%s"),
uri, error ? error:_("Unknown error"));
} else {
- log_error(LOG_PROTOCOL, _("This URL does not look like a WebCal URL:\n%s\n%s\n"),
+ log_error(LOG_PROTOCOL, _("This URL does not look like a Webcal URL:\n%s\n%s\n"),
uri, error ? error:_("Unknown error"));
}
g_free(feed);
gchar *title = feed_get_title(feed);
if (title == NULL) {
if (strstr(uri, "://"))
- title = g_strdup(strstr(uri,"://")+3);
+ title = g_path_get_basename(strstr(uri,"://")+3);
else
title = g_strdup(uri);
subst_for_filename(title);
- if (strlen(title) > 32) {
- title[29]=title[30]=title[31]='.';
- title[32]='\0';
- }
}
item = folder_create_folder(root->node->data, title);
+ if (!item) {
+ if (verbose && manual_update) {
+ alertpanel_error(_("Could not create directory %s"),
+ title);
+ } else {
+ log_error(LOG_PROTOCOL, _("Could not create directory %s"),
+ title);
+ }
+ g_free(feed);
+ g_free(title);
+ main_window_cursor_normal(mainwindow_get_mainwindow());
+ return;
+ }
debug_print("item done %s\n", title);
((VCalFolderItem *)item)->uri = g_strdup(uri);
((VCalFolderItem *)item)->feed = feed;
gchar *uri = NULL;
gchar *tmp = NULL;
- tmp = input_dialog(_("Subscribe to WebCal"), _("Enter the WebCal URL:"), NULL);
+ tmp = input_dialog(_("Subscribe to Webcal"), _("Enter the WebCal URL:"), NULL);
if (tmp == NULL)
return;
static void unsubscribe_cal_cb(GtkAction *action, gpointer data)
{
FolderView *folderview = (FolderView *)data;
- GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
- FolderItem *item;
+ FolderItem *item, *opened;
gchar *message;
AlertValue avalue;
- gchar *old_path;
gchar *old_id;
if (!folderview->selected) return;
- item = gtk_cmctree_node_get_row_data(ctree, folderview->selected);
+ item = folderview_get_selected_item(folderview);
g_return_if_fail(item != NULL);
g_return_if_fail(item->path != NULL);
g_return_if_fail(item->folder != NULL);
+ opened = folderview_get_opened_item(folderview);
message = g_strdup_printf
(_("Do you really want to unsubscribe?"));
- avalue = alertpanel_full(_("Delete folder"), message,
+ avalue = alertpanel_full(_("Delete subscription"), message,
GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL,
FALSE, NULL, ALERT_WARNING, G_ALERTDEFAULT);
g_free(message);
if (avalue != G_ALERTALTERNATE) return;
- Xstrdup_a(old_path, item->path, return);
old_id = folder_item_get_identifier(item);
vcal_item_closed(item);
- if (folderview->opened == folderview->selected ||
- gtk_cmctree_is_ancestor(ctree,
- folderview->selected,
- folderview->opened)) {
+ if (item == opened ||
+ folder_is_child_of(item, opened)) {
summary_clear_all(folderview->summaryview);
- folderview->opened = NULL;
+ folderview_close_opened(folderview, TRUE);
}
if (item->folder->klass->remove_folder(item->folder, item) < 0) {
{
FolderView *folderview = (FolderView *)data;
gint action = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
- GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
FolderItem *item = NULL, *oitem = NULL;
if (!folderview->selected) return;
if (setting_sensitivity) return;
- oitem = gtk_cmctree_node_get_row_data(ctree, folderview->opened);
- item = gtk_cmctree_node_get_row_data(ctree, folderview->selected);
+ oitem = folderview_get_opened_item(folderview);
+ item = folderview_get_selected_item(folderview);
+
+ if (!item)
+ return;
if (((VCalFolderItem *)(item))->use_cal_view == action)
return;
icalproperty_new_prodid(
"-//Claws Mail//NONSGML Claws Mail Calendar//EN"),
icalproperty_new_calscale("GREGORIAN"),
- 0);
+ (void*)0);
vcal_manager_event_dump(event, FALSE, FALSE, calendar, FALSE);
ical = g_strdup(icalcomponent_as_ical_string(calendar));
icalcomponent_free(calendar);
return email;
}
+static void adjust_for_local_time_zone(icalproperty *eventtime, icalproperty *tzoffsetto, int dtstart)
+{
+ int tzoffset;
+ int loctzoffset;
+ time_t loctime, gmttime, evttime;
+ struct icaltimetype icaltime;
+
+ /* calculate local UTC offset */
+ loctime = time(NULL);
+ loctime = mktime(localtime(&loctime));
+ gmttime = mktime(gmtime(&loctime));
+ loctzoffset = loctime - gmttime;
+
+ if (eventtime && tzoffsetto) {
+ tzoffset = icalproperty_get_tzoffsetto(tzoffsetto);
+ if (dtstart) {
+ evttime = icaltime_as_timet(icalproperty_get_dtstart(eventtime));
+ }
+ else {
+ evttime = icaltime_as_timet(icalproperty_get_dtend(eventtime));
+ }
+
+ /* convert to UTC */
+ evttime -= tzoffset;
+ /* and adjust for local time zone */
+ evttime += loctzoffset;
+ icaltime = icaltime_from_timet(evttime, 0);
+
+ if (dtstart) {
+ icalproperty_set_dtstart(eventtime, icaltime);
+ }
+ else {
+ icalproperty_set_dtend(eventtime, icaltime);
+ }
+ }
+}
+
#define GET_PROP(comp,prop,kind) { \
prop = NULL; \
if (!(prop = icalcomponent_get_first_property(comp, kind))) { \
gchar *int_ical = g_strdup(ical);
icalcomponent *comp = icalcomponent_new_from_string(int_ical);
icalcomponent *inner = NULL;
+ icalcomponent *tzcomp = NULL;
icalproperty *prop = NULL;
GSList *list = NULL, *cur = NULL;
gchar *uid = NULL;
gchar *recur = NULL;
int sequence = 0;
enum icalproperty_method method = ICAL_METHOD_REQUEST;
- enum icalproperty_kind type = ICAL_VEVENT_COMPONENT;
+ enum icalcomponent_kind type = ICAL_VEVENT_COMPONENT;
GSList *attendees = NULL;
if (comp == NULL) {
TO_UTF8(summary);
icalproperty_free(prop);
}
+ tzcomp = icalcomponent_get_first_component(comp, ICAL_VTIMEZONE_COMPONENT);
+ if (tzcomp) {
+ icalproperty *evtstart = NULL;
+ icalproperty *evtend = NULL;
+ icalproperty *tzoffsetto = NULL;
+ icalcomponent *tzstd = NULL;
+
+ tzstd = icalcomponent_get_first_component(tzcomp, ICAL_XSTANDARD_COMPONENT);
+ tzoffsetto = icalcomponent_get_first_property(tzstd, ICAL_TZOFFSETTO_PROPERTY);
+
+ GET_PROP(comp, evtstart, ICAL_DTSTART_PROPERTY);
+ adjust_for_local_time_zone(evtstart, tzoffsetto, TRUE);
+
+ GET_PROP(comp, evtend, ICAL_DTEND_PROPERTY);
+ adjust_for_local_time_zone(evtend, tzoffsetto, FALSE);
+
+ if (tzoffsetto)
+ icalproperty_free(tzoffsetto);
+ if (evtstart)
+ icalproperty_free(evtstart);
+ if (evtend)
+ icalproperty_free(evtend);
+ if (tzstd)
+ icalcomponent_free(tzstd);
+ }
GET_PROP(comp, prop, ICAL_DTSTART_PROPERTY);
if (prop) {
dtstart = g_strdup(icaltime_as_ical_string(icalproperty_get_dtstart(prop)));
struct icaltimetype itt;
icalproperty_free(prop);
GET_PROP(comp, prop, ICAL_DTSTART_PROPERTY);
- itt = icalproperty_get_dtstart(prop);
if (prop) {
+ itt = icalproperty_get_dtstart(prop);
icalproperty_free(prop);
dtend = g_strdup(icaltime_as_ical_string(icaltime_add(itt,duration)));
TO_UTF8(dtend);
info = folder_item_get_msginfo_by_msgid(folder->inbox, id);
if (info != NULL) {
- procmsg_msginfo_free(info);
+ procmsg_msginfo_free(&info);
return TRUE;
}
return FALSE;
if (info != NULL) {
debug_print("removing event %s\n", id);
vcal_remove_event(folder, info);
- procmsg_msginfo_free(info);
+ procmsg_msginfo_free(&info);
folder_item_scan(folder->inbox);
return TRUE;
}