示例#1
0
int
main (int argc, char **argv)
{
    /* init i18n */
    setlocale (LC_ALL, "");
    bindtextdomain(GETTEXT_PACKAGE, SEAFILE_LOCALE_DIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain(GETTEXT_PACKAGE);

    if (count_process("seafile-applet") > 1) {
        fprintf(stderr, _("Seafile is already running\n"));
        exit(1);
    }

    gtk_init (&argc, &argv);
    gtk_icon_theme_append_search_path (gtk_icon_theme_get_default(),
                                       PKGDATADIR);
    gtk_window_set_default_icon_name ("seafile");

    signal (SIGINT, sigint_handler);

    applet = g_new0 (SeafileApplet, 1);
    seafile_applet_init (applet);
    seafile_applet_start (argc, argv);

    applet_message ("seafile started\n");

    trayicon_set_tip ("Seafile");

    gtk_main ();

    return 0;
}
示例#2
0
/* Kill ccnet/seaf/web, and restart them. */
void restart_all (void)
{
    trayicon_set_tip ("Seafile");
    
    applet_message ("Restarting ccnet ...\n");
    stop_open_browser_timer();
    stop_web_server();
    
    if (applet->client->connected) {
        stop_ccnet();
    }
    
    spawn_ccnet_daemon();
    
    start_conn_daemon_timer (1000, NULL);
}
示例#3
0
static void
reset_trayicon_and_tip()
{
    UINT id;
    char *tip = "Seafile";

    if (!applet->client->connected) {
        id = IDI_STATUS_DOWN;
    } else {
        if (applet->auto_sync_disabled) {
            id = IDI_STATUS_AUTO_SYNC_DISABLED;
            tip = _("Auto sync is disabled");
        } else {
            id = IDI_STATUS_UP;
        }
    }

    trayicon_set_icon_by_id (applet->icon, id);
    trayicon_set_tip (tip);
}
示例#4
0
static void
handle_seafile_notification (char *type, char *content)
{
    char buf[1024];

    if (strcmp(type, "transfer") == 0) {
        if (applet->auto_sync_disabled) {
            /* When auto sync is disabled but there is clone task running,
             * applet can still get "transfer" notification, but we don't
             * rotate the icon */
            return;
        }
        trayicon_rotate (TRUE);

        if (content == NULL) {
            applet_debug ("handle empty notification\n");
            return;
        }
        GString *str = g_string_new (NULL);
        parse_key_value_pairs (content,
                               (KeyValueFunc)collect_transfer_info, str);
        trayicon_set_tip (str->str);
        g_string_free (str, TRUE);

        return;
        
    } else if (strcmp(type, "repo.deleted_on_relay") == 0) {
        snprintf (buf, sizeof(buf), "\"%s\" %s", content, _("is unsynced. \nReason: Deleted on server"));
        trayicon_notify ("Seafile", buf);
        
    } else if (strcmp(type, "sync.done") == 0) {
        /* format: repo_name \t repo_id \t description */
        char *p, *repo_name, *repo_id, *desc;
        repo_name = content;
        p = strchr(content, '\t');
        if (!p) {
            return;
        }
        *p = '\0';
        repo_id = p + 1;

        p = strchr(p + 1, '\t');
        if (!p) {
            return;
        }
        *p = '\0';
        desc = p + 1;
#ifdef __APPLE__
        char *translated_desc = g_strdup(desc);
#else
        char *translated_desc = translate_commit_desc(desc);
#endif

        memcpy (applet->last_synced_repo, repo_id, strlen(repo_id) + 1);
        snprintf (buf, sizeof(buf), "\"%s\" %s", repo_name, _("is synchronized"));
        trayicon_notify (buf, translated_desc);

        g_free (translated_desc);
        
    } else if (strcmp(type, "sync.access_denied") == 0) {
        /* format: <repo_name\trepo_id> */
        char *p = strchr(content, '\t');
        if (!p) {
            return;
        }
        *p = '\0';
        char *repo_name = content;
        char *repo_id = p + 1;

        memcpy (applet->last_synced_repo, repo_id, strlen(repo_id) + 1);
        snprintf (buf, sizeof(buf), "\"%s\" %s", repo_name, _("failed to sync. \nAccess denied to service"));
        trayicon_notify ("Seafile", buf);
    } else if (strcmp(type, "sync.quota_full") == 0) {
        /* format: <repo_name\trepo_id> */
        char *p = strchr(content, '\t');
        if (!p) {
            return;
        }
        *p = '\0';
        char *repo_name = content;
        char *repo_id = p + 1;

        memcpy (applet->last_synced_repo, repo_id, strlen(repo_id) + 1);
        snprintf (buf, sizeof(buf), "\"%s\" %s", repo_name, _("failed to sync.\nThe library owner's storage space is used up."));
        trayicon_notify ("Seafile", buf);
    }
#ifdef __APPLE__
    else if (strcmp(type, "repo.setwktree") == 0) {
        seafile_set_repofolder_icns (content);
    } else if  (strcmp(type, "repo.unsetwktree") == 0) {
        seafile_unset_repofolder_icns (content);
    }
#endif
}