void ContactGeometry::extendConnectToModel(Model& aModel) { Super::extendConnectToModel(aModel); //TODO use Connectors! try { _body = static_cast<PhysicalFrame*>(&updModel().updComponent(get_body_name())); } catch (...) { std::string errorMessage = "Invalid body (" + get_body_name() + ") specified in contact geometry " + getName(); throw (Exception(errorMessage.c_str())); } }
static int fetch_binary_size(struct imap_fetch_context *ctx, struct mail *mail, struct imap_fetch_body_data *body) { string_t *str; uoff_t size; if (mail == NULL) { imap_msgpart_free(&body->msgpart); return 1; } if (imap_msgpart_size(mail, body->msgpart, &size) < 0) return -1; str = t_str_new(128); if (ctx->state.cur_first) ctx->state.cur_first = FALSE; else str_append_c(str, ' '); str_printfa(str, "%s %"PRIuUOFF_T, get_body_name(body), size); if (o_stream_send(ctx->client->output, str_data(str), str_len(str)) < 0) return -1; return 1; }
static int fetch_binary_size(struct imap_fetch_context *ctx, struct mail *mail, struct imap_fetch_body_data *body) { string_t *str; uoff_t size; if (mail == NULL) { imap_msgpart_free(&body->msgpart); return 1; } if (imap_msgpart_size(mail, body->msgpart, &size) < 0) { if (mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_INVALIDDATA) return -1; /* tried to do BINARY.SIZE fetch for a MIME part with broken content */ size = 0; } str = t_str_new(128); if (ctx->state.cur_first) ctx->state.cur_first = FALSE; else str_append_c(str, ' '); str_printfa(str, "%s %"PRIuUOFF_T, get_body_name(body), size); if (o_stream_send(ctx->client->output, str_data(str), str_len(str)) < 0) return -1; return 1; }
void ContactGeometry::extendConnectToModel(Model& aModel) { Super::extendConnectToModel(aModel); //TODO use Connectors! try { _body = static_cast<PhysicalFrame*>(&updModel().updComponent(get_body_name())); } catch (...) { std::string errorMessage = "Invalid body (" + get_body_name() + ") specified in contact geometry " + getName(); throw (Exception(errorMessage.c_str())); } _body->updDisplayer()->addDependent(updDisplayer()); _displayer.setTransform(getTransform()); _displayer.setOwner(this); }
static string_t *get_prefix(struct imap_fetch_context *ctx, const struct imap_fetch_body_data *body, uoff_t size) { string_t *str; str = t_str_new(128); if (ctx->first) ctx->first = FALSE; else str_append_c(str, ' '); str_append(str, get_body_name(body)); if (size != (uoff_t)-1) str_printfa(str, " {%"PRIuUOFF_T"}\r\n", size); else str_append(str, " NIL"); return str; }
static string_t *get_prefix(struct imap_fetch_state *state, const struct imap_fetch_body_data *body, uoff_t size, bool has_nuls) { string_t *str; str = t_str_new(128); if (state->cur_first) state->cur_first = FALSE; else str_append_c(str, ' '); str_append(str, get_body_name(body)); if (size == (uoff_t)-1) str_append(str, " NIL"); else if (has_nuls && body->binary) str_printfa(str, " ~{%"PRIuUOFF_T"}\r\n", size); else str_printfa(str, " {%"PRIuUOFF_T"}\r\n", size); return str; }
bool imap_fetch_binary_init(struct imap_fetch_init_context *ctx) { struct imap_fetch_body_data *body; const struct imap_arg *list_args; unsigned int list_count; const char *str, *p, *error; i_assert(strncmp(ctx->name, "BINARY", 6) == 0); p = ctx->name + 6; body = p_new(ctx->pool, struct imap_fetch_body_data, 1); body->binary = TRUE; if (strncmp(p, ".SIZE", 5) == 0) { /* fetch decoded size of the section */ p += 5; body->binary_size = TRUE; } else if (strncmp(p, ".PEEK", 5) == 0) { p += 5; } else { ctx->fetch_ctx->flags_update_seen = TRUE; } if (*p != '[') { ctx->error = "Invalid BINARY[..] parameter: Missing '['"; return FALSE; } if (imap_arg_get_list_full(&ctx->args[0], &list_args, &list_count)) { /* BINARY[HEADER.FIELDS.. (headers list)] */ if (!imap_arg_get_atom(&ctx->args[1], &str) || str[0] != ']') { ctx->error = "Invalid BINARY[..] parameter: Missing ']'"; return FALSE; } if (body_header_fields_parse(ctx, body, p+1, list_args, list_count) < 0) return FALSE; p = str+1; ctx->args += 2; } else { /* no headers list */ body->section = p+1; p = strchr(body->section, ']'); if (p == NULL) { ctx->error = "Invalid BINARY[..] parameter: Missing ']'"; return FALSE; } body->section = p_strdup_until(ctx->pool, body->section, p); p++; } if (imap_msgpart_parse(body->section, &body->msgpart) < 0) { ctx->error = "Invalid BINARY[..] section"; return FALSE; } imap_msgpart_set_decode_to_binary(body->msgpart); ctx->fetch_ctx->fetch_data |= imap_msgpart_get_fetch_data(body->msgpart); if (!body->binary_size) { if (body_parse_partial(body, p, &error) < 0) { ctx->error = p_strdup_printf(ctx->pool, "Invalid BINARY[..] parameter: %s", error); return FALSE; } } /* update the section name for the imap_fetch_add_handler() */ ctx->name = p_strdup(ctx->pool, get_body_name(body)); if (body->binary_size) { imap_fetch_add_handler(ctx, IMAP_FETCH_HANDLER_FLAG_WANT_DEINIT, "0", fetch_binary_size, body); } else { imap_fetch_add_handler(ctx, IMAP_FETCH_HANDLER_FLAG_WANT_DEINIT, "NIL", fetch_body_msgpart, body); } return TRUE; }
const std::string& ContactGeometry::getBodyName() { return get_body_name(); }