本文整理匯總了C++中GMIME_IS_PART函數的典型用法代碼示例。如果您正苦於以下問題:C++ GMIME_IS_PART函數的具體用法?C++ GMIME_IS_PART怎麽用?C++ GMIME_IS_PART使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GMIME_IS_PART函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: mime_part_get_filename
static char*
mime_part_get_filename (GMimeObject *mobj, unsigned index,
gboolean construct_if_needed)
{
gchar *fname;
fname = NULL;
if (GMIME_IS_PART (mobj)) {
/* the easy case: the part has a filename */
fname = (gchar*)g_mime_part_get_filename (GMIME_PART(mobj));
if (fname) /* don't include directory components */
fname = g_path_get_basename (fname);
}
if (!fname && !construct_if_needed)
return NULL;
if (GMIME_IS_MESSAGE_PART(mobj)) {
GMimeMessage *msg;
const char *subj;
msg = g_mime_message_part_get_message
(GMIME_MESSAGE_PART(mobj));
subj = g_mime_message_get_subject (msg);
fname = g_strdup_printf ("%s.eml", subj ? subj : "message");
}
if (!fname)
fname = g_strdup_printf ("%u.part", index);
/* remove slashes, spaces, colons... */
cleanup_filename (fname);
return fname;
}
示例2: get_mime_stream
static GMimeStream*
get_mime_stream (GMimeObject *obj, GError **err)
{
GMimeStream *mstream;
GMimeDataWrapper *wrapper;
if (!GMIME_IS_PART(obj)) {
char *str;
GByteArray *ar;
str = g_mime_object_to_string (obj);
ar = g_byte_array_new_take ((guchar*)str, strlen(str));
mstream = g_mime_stream_mem_new_with_byte_array (ar);
g_mime_stream_mem_set_owner (
GMIME_STREAM_MEM(mstream), TRUE);
return mstream;
}
wrapper = get_data_wrapper (obj, err);
if (!wrapper)
return NULL;
mstream = g_mime_data_wrapper_get_stream (wrapper);
if (!mstream || g_mime_stream_reset (mstream) != 0) {
g_set_error (err, G_IO_ERROR, G_IO_ERROR_FAILED,
"invalid mime-stream");
return NULL;
}
return mstream;
}
示例3: mu_msg_part_save
gboolean
mu_msg_part_save (MuMsg *msg, MuMsgOptions opts,
const char *fullpath, guint partidx, GError **err)
{
GMimeObject *part;
g_return_val_if_fail (msg, FALSE);
g_return_val_if_fail (fullpath, FALSE);
g_return_val_if_fail (!((opts & MU_MSG_OPTION_OVERWRITE) &&
(opts & MU_MSG_OPTION_USE_EXISTING)), FALSE);
if (!mu_msg_load_msg_file (msg, err))
return FALSE;
part = get_mime_object_at_index (msg, opts, partidx);
if (!GMIME_IS_PART(part) || GMIME_IS_MESSAGE_PART(part)) {
g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_GMIME,
"unexpected type %s for part %u",
G_OBJECT_TYPE_NAME((GObject*)part),
partidx);
return FALSE;
}
return save_object (part, opts, fullpath, err);
}
示例4: g_mime_part_get_content_id
/**
* g_mime_part_get_content_id:
* @mime_part: a #GMimePart object
*
* Gets the content-id of the specified mime part if it exists, or
* %NULL otherwise.
*
* Returns: the content id for the specified mime part.
**/
const char *
g_mime_part_get_content_id (GMimePart *mime_part)
{
g_return_val_if_fail (GMIME_IS_PART (mime_part), NULL);
return g_mime_object_get_content_id (GMIME_OBJECT (mime_part));
}
示例5: g_mime_part_set_content_id
/**
* g_mime_part_set_content_id:
* @mime_part: a #GMimePart object
* @content_id: content id
*
* Set the content id for the specified mime part.
**/
void
g_mime_part_set_content_id (GMimePart *mime_part, const char *content_id)
{
g_return_if_fail (GMIME_IS_PART (mime_part));
g_mime_object_set_content_id (GMIME_OBJECT (mime_part), content_id);
}
示例6: part_extractor_foreach_callback
static void part_extractor_foreach_callback(GMimeObject *parent, GMimeObject *part, gpointer user_data) {
PartExtractorData *a_data = (PartExtractorData *) user_data;
if (GMIME_IS_MESSAGE_PART(part)) {
if (a_data->recursion_depth < RECURSION_LIMIT) {
GMimeMessage *message = g_mime_message_part_get_message((GMimeMessagePart *) part); // transfer none
if (message)
g_mime_message_foreach(message, part_extractor_foreach_callback, a_data);
} else {
g_printerr("endless recursion detected: %d\r\n", a_data->recursion_depth);
return;
}
} else if (GMIME_IS_MESSAGE_PARTIAL (part)) {
// Save into an array ? Todo: Look into the specs
} else if (GMIME_IS_MULTIPART (part)) {
// Nothing special needed on multipart, let descend further
} else if (GMIME_IS_PART (part)) {
// We are interested only in the part 0 (counting down by same logic)
if (a_data->part_id == 0)
extract_part(part, a_data);
a_data->part_id--;
} else {
g_assert_not_reached();
}
}
示例7: g_mime_part_get_content_location
/**
* g_mime_part_get_content_location:
* @mime_part: a #GMimePart object
*
* Gets the value of the Content-Location header if it exists, or
* %NULL otherwise.
*
* Returns: the content location for the specified mime part.
**/
const char *
g_mime_part_get_content_location (GMimePart *mime_part)
{
g_return_val_if_fail (GMIME_IS_PART (mime_part), NULL);
return mime_part->content_location;
}
示例8: g_mime_part_get_content_encoding
/**
* g_mime_part_get_content_encoding:
* @mime_part: a #GMimePart object
*
* Gets the content encoding of the mime part.
*
* Returns: the content encoding for the specified mime part.
**/
GMimeContentEncoding
g_mime_part_get_content_encoding (GMimePart *mime_part)
{
g_return_val_if_fail (GMIME_IS_PART (mime_part), GMIME_CONTENT_ENCODING_DEFAULT);
return mime_part->encoding;
}
示例9: g_mime_object_get_content_type
QNetworkReply*
MailNetworkManager::makeReply(const QNetworkRequest& req, GMimeObject* content)
{
auto ctype = g_mime_object_get_content_type(content);
char *mtstr = g_mime_content_type_to_string(ctype);
QString mediaType = QString::fromUtf8(mtstr);
g_free(mtstr);
const char *enc = g_mime_content_type_get_parameter(ctype, "charset");
if (enc != NULL) {
mediaType += "; charset=\"";
mediaType += QString::fromUtf8(enc);
mediaType += "\"";
}
g_return_val_if_fail(GMIME_IS_PART(content), NULL);
GMimeStream *stream = g_mime_stream_mem_new();
GMimeDataWrapper *wrapper = g_mime_part_get_content_object(GMIME_PART(content));
g_mime_data_wrapper_write_to_stream(wrapper, stream);
GByteArray *bytes = g_mime_stream_mem_get_byte_array(GMIME_STREAM_MEM(stream));
QByteArray buffer((const char*) bytes->data, bytes->len);
g_object_unref(stream);
qDebug() <<"making reply of length" <<buffer.size() <<"and type" <<mediaType;
return StaticHTTPReply::ok(req, buffer, mediaType);
}
示例10: format_part_content_raw
static void
format_part_content_raw (GMimeObject *part)
{
if (! GMIME_IS_PART (part))
return;
GMimeStream *stream_stdout;
GMimeStream *stream_filter = NULL;
GMimeDataWrapper *wrapper;
stream_stdout = g_mime_stream_file_new (stdout);
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
stream_filter = g_mime_stream_filter_new (stream_stdout);
wrapper = g_mime_part_get_content_object (GMIME_PART (part));
if (wrapper && stream_filter)
g_mime_data_wrapper_write_to_stream (wrapper, stream_filter);
if (stream_filter)
g_object_unref (stream_filter);
if (stream_stdout)
g_object_unref(stream_stdout);
}
示例11: process_message_callback
static void process_message_callback(GMimeObject *part, gpointer user_data)
{
struct mime_cbinfo *cbinfo = user_data;
cbinfo->count++;
/* We strip off the headers before we get here, so should only see GMIME_IS_PART */
if (GMIME_IS_MESSAGE_PART(part)) {
ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MESSAGE_PART\n");
return;
} else if (GMIME_IS_MESSAGE_PARTIAL(part)) {
ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MESSAGE_PARTIAL\n");
return;
} else if (GMIME_IS_MULTIPART(part)) {
GList *l;
ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MULTIPART, trying to process subparts\n");
l = GMIME_MULTIPART(part)->subparts;
while (l) {
process_message_callback(l->data, cbinfo);
l = l->next;
}
} else if (GMIME_IS_PART(part)) {
const char *filename;
if (ast_strlen_zero(filename = g_mime_part_get_filename(GMIME_PART(part)))) {
ast_debug(1, "Skipping part with no filename\n");
return;
}
post_raw(GMIME_PART(part), cbinfo->post_dir, filename);
} else {
ast_log(LOG_ERROR, "Encountered unknown MIME part. This should never happen!\n");
}
}
示例12: g_mime_part_get_content_object
/**
* g_mime_part_get_content_object:
* @mime_part: a #GMimePart object
*
* Gets the internal data-wrapper of the specified mime part, or %NULL
* on error.
*
* Returns: (transfer none): the data-wrapper for the mime part's
* contents.
**/
GMimeDataWrapper *
g_mime_part_get_content_object (GMimePart *mime_part)
{
g_return_val_if_fail (GMIME_IS_PART (mime_part), NULL);
return mime_part->content;
}
示例13: collector_foreach_callback
static void collector_foreach_callback(GMimeObject *parent, GMimeObject *part, gpointer user_data) {
g_return_if_fail(user_data != NULL);
PartCollectorData *fdata = (PartCollectorData *) user_data;
if (GMIME_IS_MESSAGE_PART(part)) {
if (fdata->recursion_depth++ < RECURSION_LIMIT) {
GMimeMessage *message = g_mime_message_part_get_message((GMimeMessagePart *) part); // transfer none
if (message)
g_mime_message_foreach(message, collector_foreach_callback, user_data);
} else {
g_printerr("endless recursion detected: %d\r\n", fdata->recursion_depth);
return;
}
} else if (GMIME_IS_MESSAGE_PARTIAL(part)) {
// Save into an array ? Todo: Look into the specs
} else if (GMIME_IS_MULTIPART(part)) {
// Nothing special needed on multipart, let descend further
} else if (GMIME_IS_PART(part)) {
collect_part(part, fdata, GMIME_IS_MULTIPART(parent));
fdata->part_id++;
} else {
g_assert_not_reached();
}
}
示例14: g_mime_part_get_best_content_encoding
/**
* g_mime_part_get_best_content_encoding:
* @mime_part: a #GMimePart object
* @constraint: a #GMimeEncodingConstraint
*
* Calculates the most efficient content encoding for the @mime_part
* given the @constraint.
*
* Returns: the best content encoding for the specified mime part.
**/
GMimeContentEncoding
g_mime_part_get_best_content_encoding (GMimePart *mime_part, GMimeEncodingConstraint constraint)
{
GMimeStream *filtered, *stream;
GMimeContentEncoding encoding;
GMimeFilterBest *best;
GMimeFilter *filter;
g_return_val_if_fail (GMIME_IS_PART (mime_part), GMIME_CONTENT_ENCODING_DEFAULT);
stream = g_mime_stream_null_new ();
filtered = g_mime_stream_filter_new (stream);
g_object_unref (stream);
filter = g_mime_filter_best_new (GMIME_FILTER_BEST_ENCODING);
g_mime_stream_filter_add ((GMimeStreamFilter *) filtered, filter);
best = (GMimeFilterBest *) filter;
g_mime_data_wrapper_write_to_stream (mime_part->content, filtered);
g_mime_stream_flush (filtered);
g_object_unref (filtered);
encoding = g_mime_filter_best_encoding (best, constraint);
g_object_unref (best);
return encoding;
}
示例15: accumulate_body
static void
accumulate_body (MuMsg *msg, MuMsgPart *mpart, BodyData *bdata)
{
char *txt;
gboolean err;
/* if it looks like an attachment, skip it */
if (mpart->part_type & MU_MSG_PART_TYPE_ATTACHMENT)
return;
if (!GMIME_IS_PART(mpart->data))
return;
txt = NULL;
err = TRUE;
if (!bdata->want_html &&
(mpart->part_type & MU_MSG_PART_TYPE_TEXT_PLAIN))
txt = mu_msg_mime_part_to_string (
(GMimePart*)mpart->data, &err);
else if (bdata->want_html &&
(mpart->part_type & MU_MSG_PART_TYPE_TEXT_HTML))
txt = mu_msg_mime_part_to_string (
(GMimePart*)mpart->data, &err);
if (!err && txt)
bdata->gstr = g_string_append (bdata->gstr, txt);
g_free (txt);
}