示例#1
0
/* Ask ccnet daemon to quit, and disconnect client from daemon. */
void
stop_ccnet (void)
{
    CcnetClient *client = applet->client;
    CcnetClient *sync_client = applet->sync_client;
    
    if (!client)
        return;

    if (client->connected) {
        stop_mq_client ();
        
        send_command ("shutdown");
        ccnet_client_disconnect_daemon (client);
        if (sync_client && sync_client->connected)
            ccnet_client_disconnect_daemon (sync_client);

        trayicon_rotate (FALSE);

        rm_client_fd_from_mainloop ();
    }

    if (applet->heartbeat_monitor_on)
        stop_heartbeat_monitor ();

    trayicon_set_ccnet_state (CCNET_STATE_DOWN);
}
示例#2
0
void 
on_ccnet_daemon_down (void)
{
    applet_warning ("Connection to daemon is down.\n");
    trayicon_rotate (FALSE);
    trayicon_set_ccnet_state (CCNET_STATE_DOWN);
    
    if (applet->client->connected) {
        ccnet_client_disconnect_daemon (applet->client);
        if (applet->sync_client->connected)
            ccnet_client_disconnect_daemon (applet->sync_client);
    }
}
示例#3
0
int
tray_command_cb (UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(wParam) {
    case IDM_OPEN:
        if (applet->web_status == WEB_READY) {
            open_web_browser (SEAF_HTTP_ADDR);
        }
        break;

    case IDM_DISABLE_AUTO_SYNC: {
        seafile_disable_auto_sync();
        break;
    }
                                      
    case IDM_ENABLE_AUTO_SYNC: {
        seafile_enable_auto_sync();
        break;
    }
        
    case IDM_RESTART:
        trayicon_rotate (FALSE);
        restart_all();
        break;
        
    case IDM_EXIT:
        PostQuitMessage(0);
        applet_exit(0);
        break;

    default:
        break;
    }

    return TRUE;
}
示例#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
}