static void read_done_cb (OSAsyncResult *res, void *cb_data) { CcnetProcessor *processor = cb_data; USE_PRIV; if (!res->success) { g_warning ("[putcommit] Failed to read %s.\n", res->obj_id); goto bad; } send_commit (processor, res->obj_id, res->data, res->len); seaf_debug ("Send commit %.8s.\n", res->obj_id); /* Send next commit. */ if (priv->id_list != NULL) read_and_send_commit (processor); else { ccnet_processor_send_response (processor, SC_END, SS_END, NULL, 0); ccnet_processor_done (processor, TRUE); } return; bad: ccnet_processor_send_response (processor, SC_NOT_FOUND, SS_NOT_FOUND, NULL, 0); ccnet_processor_done (processor, FALSE); }
static void handle_response (CcnetProcessor *processor, char *code, char *code_msg, char *content, int clen) { SeafileSendcommitV4Proc *proc = (SeafileSendcommitV4Proc *)processor; TransferTask *task = proc->tx_task; if (task->state != TASK_STATE_NORMAL) { ccnet_processor_done (processor, TRUE); return; } switch (processor->state) { case INIT: if (memcmp (code, SC_OK, 3) == 0) { processor->state = SEND_OBJECT; send_commit (processor, task->head); return; } break; case SEND_OBJECT: if (memcmp (code, SC_ACK, 3) == 0) { ccnet_processor_done (processor, TRUE); return; } break; default: g_return_if_reached (); } seaf_warning ("Bad response: %s %s.\n", code, code_msg); if (memcmp (code, SC_ACCESS_DENIED, 3) == 0) transfer_task_set_error (task, TASK_ERR_ACCESS_DENIED); ccnet_processor_done (processor, FALSE); }
static void send_commits (CcnetProcessor *processor, char *content, int clen) { char *object_id; int n_objects; int i; if (clen % 41 != 1 || content[clen-1] != '\0') { g_warning ("[putcommit] Bad fs object list.\n"); ccnet_processor_send_response (processor, SC_BAD_OL, SS_BAD_OL, NULL, 0); ccnet_processor_done (processor, FALSE); return; } n_objects = clen/41; g_debug ("[putcommit] send commit objects %d:\n%s", n_objects, content); object_id = content; for (i = 0; i < n_objects; ++i) { object_id[40] = '\0'; g_debug ("[putcommit] send commit object #%d:%s\n", i, object_id); if (send_commit (processor, object_id) == FALSE) return; object_id += 41; } }
bool XYVirtualKeyboard::enter_clicked() { if (letterLabel->text().isEmpty()) { return false; } emit send_commit(letterLabel->text()); clear_history(); return true; }
void s4pp_flush (s4pp_ctx_t *ctx, s4pp_done_fn done) { if (ctx->state != S4PP_BUFFERING) done (ctx, true); else { ctx->done = done; if (ctx->waiting_for_sent) ctx->want_commit_on_sent = true; else send_commit (ctx); } }
bool s4pp_on_sent (s4pp_ctx_t *ctx) { ctx->err = S4PP_OK; // clear earlier errors ctx->waiting_for_sent = false; if (ctx->want_commit_on_sent) { ctx->want_commit_on_sent = false; send_commit (ctx); } else progress_work (ctx); return_res; }
static void send_one_commit (CcnetProcessor *processor) { USE_PRIV; char *commit_id; if (!priv->id_list) { ccnet_processor_send_update (processor, SC_END, SS_END, NULL, 0); ccnet_processor_done (processor, TRUE); return; } commit_id = priv->id_list->data; priv->id_list = g_list_delete_link (priv->id_list, priv->id_list); send_commit (processor, commit_id); g_free (commit_id); }
static gboolean traverse_commit (SeafCommit *commit, void *data, gboolean *stop) { CcnetProcessor *processor = data; TransferTask *task = ((SeafileSendcommitV2Proc *)processor)->tx_task; USE_PRIV; if (priv->end_commit_id[0] != 0 && strcmp (priv->end_commit_id, commit->commit_id) == 0) { *stop = TRUE; return TRUE; } send_commit (processor, commit->commit_id); if (strcmp (commit->root_id, EMPTY_SHA1) != 0) object_list_insert (task->fs_roots, commit->root_id); return TRUE; }
static void send_commits (CcnetProcessor *processor, char *content, int clen) { char *object_id; int n_objects; int i; if (clen % 41 != 1 || content[clen-1] != '\0') { seaf_warning ("Bad fs object list.\n"); ccnet_processor_send_update (processor, SC_BAD_OL, SS_BAD_OL, NULL, 0); ccnet_processor_done (processor, FALSE); return; } n_objects = clen/41; object_id = content; for (i = 0; i < n_objects; ++i) { object_id[40] = '\0'; if (send_commit (processor, object_id) == FALSE) return; object_id += 41; } }
static void progress_work (s4pp_ctx_t *ctx) { switch (ctx->state) { case S4PP_INIT: case S4PP_CONNECT: // if connect failed, we need to retry the connect if (!ctx->conn && !ctx->fatal) { ctx->conn = ctx->io->connect (ctx->server); ctx->state = S4PP_CONNECT; } break; case S4PP_HELLO: break; // waiting for hello, nothing to do case S4PP_AUTHED: if (!ctx->next) break; // nothing to do, leave the session alone if (!prepare_begin_seq (ctx)) break; // else fall-through case S4PP_BUFFERING: while (ctx->state == S4PP_BUFFERING && process_out_buffer (ctx, false)) { bool sig = false; if (ctx->seq.n_sent >= ctx->seq.n_max) sig = true; else { s4pp_sample_t sample; if (ctx->next (ctx, &sample)) { unsigned idx; if (!prepare_dict_entry (ctx, sample.name, &idx)) break; prepare_sample_entry (ctx, &sample, idx); } else { ctx->next = NULL; // mark end of this batch if (ctx->done) sig = true; else break; } } if (sig) send_commit (ctx); } break; case S4PP_COMMITTING: // waiting for OK/NOK // we might only have buffered the SIG: in the overflow area, so // ensure we flush it out in that case. if (ctx->outbuf.used) process_out_buffer (ctx, true); break; case S4PP_ERRORED: default: // We have work to do, but something went wrong, so reconnect if possible if (ctx->conn) ctx->io->disconnect (ctx->conn); ctx->conn = NULL; ctx->err = S4PP_OK; if (!ctx->fatal) { ctx->conn = ctx->io->connect (ctx->server); ctx->state = S4PP_CONNECT; } else ctx->state = S4PP_ERRORED; break; } }