if( !is_dir_exist(rssyl_dir) ) {
if( make_dir(rssyl_dir) < 0 ) {
- g_warning("couldn't create directory %s\n", rssyl_dir);
+ g_warning("couldn't create directory %s", rssyl_dir);
}
debug_print("RSSyl: created directory %s\n", rssyl_dir);
else
rssyl_update_format();
- prefs_toolbar_register_plugin_item(TOOLBAR_MAIN, "RSSyl", _("Refresh all feeds"), rssyl_toolbar_cb_refresh_all_feeds, NULL);
+ prefs_toolbar_register_plugin_item(TOOLBAR_MAIN, PLUGIN_NAME, _("Refresh all feeds"), rssyl_toolbar_cb_refresh_all_feeds, NULL);
if( rssyl_prefs_get()->refresh_on_startup &&
claws_is_starting() )
{
rssyl_opml_export();
- prefs_toolbar_unregister_plugin_item(TOOLBAR_MAIN, "RSSyl", _("Refresh all feeds"));
+ prefs_toolbar_unregister_plugin_item(TOOLBAR_MAIN, PLUGIN_NAME, _("Refresh all feeds"));
rssyl_prefs_done();
rssyl_gtk_done();
static void rssyl_get_last_num(Folder *folder, FolderItem *item)
{
gchar *path;
- DIR *dp;
- struct dirent *d;
+ const char *f;
+ GDir *dp;
+ GError *error = NULL;
gint max = 0;
gint num;
path = folder_item_get_path(item);
g_return_if_fail(path != NULL);
- if( (dp = opendir(path)) == NULL ) {
- FILE_OP_ERROR(item->path, "opendir");
+ if( (dp = g_dir_open(path, 0, &error)) == NULL ) {
+ FILE_OP_ERROR(item->path, "g_dir_open");
+ debug_print("g_dir_open() failed on \"%s\", error %d (%s).\n",
+ path, error->code, error->message);
+ g_error_free(error);
g_free(path);
return;
}
g_free(path);
- while( (d = readdir(dp)) != NULL ) {
- if( (num = to_number(d->d_name)) > 0 && dirent_is_regular_file(d) ) {
+ while( (f = g_dir_read_name(dp)) != NULL) {
+ if ((num = to_number(f)) > 0 &&
+ g_file_test(f, G_FILE_TEST_IS_REGULAR)) {
if( max < num )
max = num;
}
}
- closedir(dp);
+ g_dir_close(dp);
debug_print("Last number in dir %s = %d\n", item->path, max);
item->last_num = max;
g_free(ritem->url);
ritem->url = g_strdup(attr->value);
}
+ /* (int) URL auth */
+ if (!strcmp(attr->name, "auth")) {
+ ritem->auth->type = atoi(attr->value);
+ }
+ /* (str) Auth user */
+ if (!strcmp(attr->name, "auth_user")) {
+ g_free(ritem->auth->username);
+ ritem->auth->username = g_strdup(attr->value);
+ }
+ /* (str) Auth pass - save directly to password store */
+ if (!strcmp(attr->name, "auth_pass")) {
+ gsize len = 0;
+ guchar *pwd = g_base64_decode(attr->value, &len);
+ memset(attr->value, 0, strlen(attr->value));
+ rssyl_passwd_set(ritem, (gchar *)pwd);
+ memset(pwd, 0, strlen(pwd));
+ g_free(pwd);
+ }
/* (str) Official title */
if( !strcmp(attr->name, "official_title")) {
g_free(ritem->official_title);
/* (str) URL */
if( ri->url != NULL )
xml_tag_add_attr(tag, xml_attr_new("uri", ri->url));
+ /* (int) Auth */
+ tmp = g_strdup_printf("%d", ri->auth->type);
+ xml_tag_add_attr(tag, xml_attr_new("auth", tmp));
+ g_free(tmp);
+ /* (str) Auth user */
+ if (ri->auth->username != NULL)
+ xml_tag_add_attr(tag, xml_attr_new("auth_user", ri->auth->username));
/* (str) Official title */
if( ri->official_title != NULL )
xml_tag_add_attr(tag, xml_attr_new("official_title", ri->official_title));
RFolderItem *ritem = g_new0(RFolderItem, 1);
ritem->url = NULL;
+ ritem->auth = g_new0(FeedAuth, 1);
+ ritem->auth->type = FEED_AUTH_NONE;
+ ritem->auth->username = NULL;
+ ritem->auth->password = NULL;
ritem->official_title = NULL;
ritem->source_id = NULL;
ritem->items = NULL;
g_return_if_fail(ritem != NULL);
g_free(ritem->url);
+ if (ritem->auth->username)
+ g_free(ritem->auth->username);
+ if (ritem->auth->password)
+ g_free(ritem->auth->password);
+ g_free(ritem->auth);
g_free(ritem->official_title);
g_slist_free(ritem->items);
g_return_val_if_fail(folder != NULL, NULL);
g_return_val_if_fail(item != NULL, NULL);
- debug_print("RSSyl: item_get_path\n");
-
name = folder_item_get_name(rssyl_get_root_folderitem(item));
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, RSSYL_DIR,
- G_DIR_SEPARATOR_S, name, G_DIR_SEPARATOR_S, item->path, NULL);
+ G_DIR_SEPARATOR_S, name, item->path, NULL);
g_free(name);
return path;
oldpathlen = strlen(oldpath);
if (strncmp(oldpath, item->path, oldpathlen) != 0) {
- g_warning("path doesn't match: %s, %s\n", oldpath, item->path);
+ g_warning("path doesn't match: %s, %s", oldpath, item->path);
return TRUE;
}
path = folder_item_get_path(item);
if( remove_dir_recursive(path) < 0 ) {
- g_warning("can't remove directory '%s'\n", path);
+ g_warning("can't remove directory '%s'", path);
g_free(path);
return -1;
}
MsgNumberList **list, gboolean *old_uids_valid)
{
gchar *path;
- DIR *dp;
- struct dirent *d;
+ GDir *dp;
+ const gchar *d;
+ GError *error = NULL;
gint num, nummsgs = 0;
g_return_val_if_fail(item != NULL, -1);
path = folder_item_get_path(item);
g_return_val_if_fail(path != NULL, -1);
- if( (dp = opendir(path)) == NULL ) {
- FILE_OP_ERROR(item->path, "opendir");
+ if( (dp = g_dir_open(path, 0, &error)) == NULL ) {
+ debug_print("g_dir_open() failed on \"%s\", error %d (%s).\n",
+ path, error->code, error->message);
+ g_error_free(error);
g_free(path);
return -1;
}
g_free(path);
- while( (d = readdir(dp)) != NULL ) {
- if( (num = to_number(d->d_name)) > 0 ) {
+ while( (d = g_dir_read_name(dp)) != NULL ) {
+ if( (num = to_number(d)) > 0 ) {
*list = g_slist_prepend(*list, GINT_TO_POINTER(num));
nummsgs++;
}
}
-
- closedir(dp);
+ g_dir_close(dp);
debug_print("RSSyl: get_num_list: returning %d\n", nummsgs);
static gboolean rssyl_is_msg_changed(Folder *folder, FolderItem *item,
MsgInfo *msginfo)
{
- struct stat s;
+ GStatBuf s;
gchar *path = NULL;
+ gchar *itempath = NULL;
g_return_val_if_fail(folder != NULL, FALSE);
g_return_val_if_fail(item != NULL, FALSE);
g_return_val_if_fail(msginfo != NULL, FALSE);
- path = g_strconcat(folder_item_get_path(item), G_DIR_SEPARATOR_S,
- itos(msginfo->msgnum), NULL);
+ itempath = folder_item_get_path(item);
+ path = g_strconcat(itempath, G_DIR_SEPARATOR_S, itos(msginfo->msgnum), NULL);
+ g_free(itempath);
if (g_stat(path, &s) < 0 ||
msginfo->size != s.st_size || (
g_return_val_if_fail(destfile != NULL, -1);
debug_print("RSSyl: add_msgs: new filename is '%s'\n", destfile);
- if( link(fileinfo->file, destfile) < 0 ) {
- if( copy_file(fileinfo->file, destfile, TRUE) < 0 ) {
- g_warning("can't copy message %s to %s\n", fileinfo->file, destfile);
- g_free(destfile);
- return -1;
- }
+ if( copy_file(fileinfo->file, destfile, TRUE) < 0 ) {
+ g_warning("can't copy message %s to %s", fileinfo->file, destfile);
+ g_free(destfile);
+ return -1;
}
if( relation != NULL )
newitem->url = g_strdup(olditem->url);
}
+ if (olditem->auth != NULL) {
+ if (newitem->auth != NULL) {
+ if (newitem->auth->username != NULL) {
+ g_free(newitem->auth->username);
+ newitem->auth->username = NULL;
+ }
+ if (newitem->auth->password != NULL) {
+ g_free(newitem->auth->password);
+ newitem->auth->password = NULL;
+ }
+ g_free(newitem->auth);
+ }
+ newitem->auth = g_new0(FeedAuth, 1);
+ newitem->auth->type = olditem->auth->type;
+ if (olditem->auth->username != NULL)
+ newitem->auth->username = g_strdup(olditem->auth->username);
+ if (olditem->auth->password != NULL)
+ newitem->auth->password = g_strdup(olditem->auth->password);
+ }
+
if (olditem->official_title != NULL) {
g_free(newitem->official_title);
newitem->official_title = g_strdup(olditem->official_title);
if( rssyl_class.idstr == NULL ) {
rssyl_class.type = F_UNKNOWN;
rssyl_class.idstr = "rssyl";
- rssyl_class.uistr = "RSSyl";
+ rssyl_class.uistr = PLUGIN_NAME;
/* Folder functions */
rssyl_class.new_folder = rssyl_new_folder;