Пример #1
0
static void CALLBACK
TestWebServer (HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime)
{
    if (test_web_server()) {
        KillTimer(hwnd, iTimerID);

        applet_message ("Web server is up.\n");

        applet->web_status = WEB_READY;
        trayicon_notify (_("Seafile is started"), _("Click the icon to open admin console"));
    }
}
Пример #2
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
}