mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-04 10:19:16 +02:00
Merge pull request #393 from deltachat/cleanup3
remove deprecated dc_send_X_msg() functions
This commit is contained in:
commit
25e157b71f
3 changed files with 3 additions and 279 deletions
|
@ -130,7 +130,9 @@ class Chat(object):
|
|||
"""
|
||||
path = as_dc_charpointer(path)
|
||||
mtype = as_dc_charpointer(mime_type)
|
||||
msg_id = lib.dc_send_file_msg(self._dc_context, self.id, path, mtype)
|
||||
msg = Message.new(self._dc_context, "file")
|
||||
msg.set_file(path, mtype)
|
||||
msg_id = lib.dc_send_msg(self._dc_context, self.id, msg._dc_msg)
|
||||
if msg_id == 0:
|
||||
raise ValueError("message could not be send, does chat exist?")
|
||||
return Message.from_db(self._dc_context, msg_id)
|
||||
|
|
272
src/dc_chat.c
272
src/dc_chat.c
|
@ -2272,278 +2272,6 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Deprecated, use dc_send_msg() instead.
|
||||
* Send an image to a chat.
|
||||
*
|
||||
* Sends the event #DC_EVENT_MSGS_CHANGED on succcess.
|
||||
* However, this does not imply, the message really reached the recipient -
|
||||
* sending may be delayed eg. due to network problems. However, from your
|
||||
* view, you're done with the message. Sooner or later it will find its way.
|
||||
*
|
||||
* See also dc_send_text_msg().
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object as returned from dc_context_new().
|
||||
* @param chat_id Chat ID to send the image to.
|
||||
* @param file Full path of the image file to send. The core may make a copy of the file.
|
||||
* @param filemime Mime type of the file to send. NULL if you don't know or don't care.
|
||||
* @param width Width in pixel of the file. 0 if you don't know or don't care.
|
||||
* @param height Width in pixel of the file. 0 if you don't know or don't care.
|
||||
* @return The ID of the message that is about being sent.
|
||||
*/
|
||||
uint32_t dc_send_image_msg(dc_context_t* context, uint32_t chat_id, const char* file, const char* filemime, int width, int height)
|
||||
{
|
||||
dc_msg_t* msg = dc_msg_new_untyped(context);
|
||||
uint32_t ret = 0;
|
||||
|
||||
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || chat_id<=DC_CHAT_ID_LAST_SPECIAL || file==NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
msg->type = DC_MSG_IMAGE;
|
||||
dc_param_set (msg->param, DC_PARAM_FILE, file);
|
||||
if (width>0 && height>0) {
|
||||
dc_param_set_int(msg->param, DC_PARAM_WIDTH, width);
|
||||
dc_param_set_int(msg->param, DC_PARAM_HEIGHT, height);
|
||||
}
|
||||
|
||||
ret = dc_send_msg(context, chat_id, msg);
|
||||
|
||||
cleanup:
|
||||
dc_msg_unref(msg);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Deprecated, use dc_send_msg() instead.
|
||||
* Send a video to a chat.
|
||||
*
|
||||
* Sends the event #DC_EVENT_MSGS_CHANGED on succcess.
|
||||
* However, this does not imply, the message really reached the recipient -
|
||||
* sending may be delayed eg. due to network problems. However, from your
|
||||
* view, you're done with the message. Sooner or later it will find its way.
|
||||
*
|
||||
* See also dc_send_image_msg().
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object as returned from dc_context_new().
|
||||
* @param chat_id Chat ID to send the video to.
|
||||
* @param file Full path of the video file to send. The core may make a copy of the file.
|
||||
* @param filemime Mime type of the file to send. NULL if you don't know or don't care.
|
||||
* @param width Width in video of the file, if known. 0 if you don't know or don't care.
|
||||
* @param height Height in video of the file, if known. 0 if you don't know or don't care.
|
||||
* @param duration Length of the video in milliseconds. 0 if you don't know or don't care.
|
||||
* @return The ID of the message that is about being sent.
|
||||
*/
|
||||
uint32_t dc_send_video_msg(dc_context_t* context, uint32_t chat_id, const char* file, const char* filemime, int width, int height, int duration)
|
||||
{
|
||||
dc_msg_t* msg = dc_msg_new_untyped(context);
|
||||
uint32_t ret = 0;
|
||||
|
||||
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || chat_id<=DC_CHAT_ID_LAST_SPECIAL || file==NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
msg->type = DC_MSG_VIDEO;
|
||||
dc_param_set (msg->param, DC_PARAM_FILE, file);
|
||||
dc_param_set (msg->param, DC_PARAM_MIMETYPE, filemime);
|
||||
if (width>0 && height>0) {
|
||||
dc_param_set_int(msg->param, DC_PARAM_WIDTH, width);
|
||||
dc_param_set_int(msg->param, DC_PARAM_HEIGHT, height);
|
||||
}
|
||||
if (duration>0) {
|
||||
dc_param_set_int(msg->param, DC_PARAM_DURATION, duration);
|
||||
}
|
||||
|
||||
ret = dc_send_msg(context, chat_id, msg);
|
||||
|
||||
cleanup:
|
||||
dc_msg_unref(msg);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Deprecated, use dc_send_msg() instead.
|
||||
* Send a voice message to a chat. Voice messages are messages just recorded through the device microphone.
|
||||
* For sending music or other audio data, use dc_send_audio_msg().
|
||||
*
|
||||
* Sends the event #DC_EVENT_MSGS_CHANGED on succcess.
|
||||
* However, this does not imply, the message really reached the recipient -
|
||||
* sending may be delayed eg. due to network problems. However, from your
|
||||
* view, you're done with the message. Sooner or later it will find its way.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object as returned from dc_context_new().
|
||||
* @param chat_id Chat ID to send the voice message to.
|
||||
* @param file Full path of the file to send. The core may make a copy of the file.
|
||||
* @param filemime Mime type of the file to send. NULL if you don't know or don't care.
|
||||
* @param duration Length of the voice message in milliseconds. 0 if you don't know or don't care.
|
||||
* @return The ID of the message that is about being sent.
|
||||
*/
|
||||
uint32_t dc_send_voice_msg(dc_context_t* context, uint32_t chat_id, const char* file, const char* filemime, int duration)
|
||||
{
|
||||
dc_msg_t* msg = dc_msg_new_untyped(context);
|
||||
uint32_t ret = 0;
|
||||
|
||||
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || chat_id<=DC_CHAT_ID_LAST_SPECIAL || file==NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
msg->type = DC_MSG_VOICE;
|
||||
dc_param_set (msg->param, DC_PARAM_FILE, file);
|
||||
dc_param_set (msg->param, DC_PARAM_MIMETYPE, filemime);
|
||||
if (duration>0) {
|
||||
dc_param_set_int(msg->param, DC_PARAM_DURATION, duration);
|
||||
}
|
||||
|
||||
ret = dc_send_msg(context, chat_id, msg);
|
||||
|
||||
cleanup:
|
||||
dc_msg_unref(msg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Deprecated, use dc_send_msg() instead.
|
||||
* Send an audio file to a chat. Audio messages are eg. music tracks.
|
||||
* For voice messages just recorded though the device microphone, use dc_send_voice_msg().
|
||||
*
|
||||
* Sends the event #DC_EVENT_MSGS_CHANGED on succcess.
|
||||
* However, this does not imply, the message really reached the recipient -
|
||||
* sending may be delayed eg. due to network problems. However, from your
|
||||
* view, you're done with the message. Sooner or later it will find its way.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object as returned from dc_context_new().
|
||||
* @param chat_id Chat ID to send the audio to.
|
||||
* @param file Full path of the file to send. The core may make a copy of the file.
|
||||
* @param filemime Mime type of the file to send. NULL if you don't know or don't care.
|
||||
* @param duration Length of the audio in milliseconds. 0 if you don't know or don't care.
|
||||
* @param author Author or artist of the file. NULL if you don't know or don't care.
|
||||
* @param trackname Trackname or title of the file. NULL if you don't know or don't care.
|
||||
* @return The ID of the message that is about being sent.
|
||||
*/
|
||||
uint32_t dc_send_audio_msg(dc_context_t* context, uint32_t chat_id, const char* file, const char* filemime, int duration, const char* author, const char* trackname)
|
||||
{
|
||||
dc_msg_t* msg = dc_msg_new_untyped(context);
|
||||
uint32_t ret = 0;
|
||||
|
||||
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || chat_id<=DC_CHAT_ID_LAST_SPECIAL || file==NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
msg->type = DC_MSG_AUDIO;
|
||||
dc_param_set (msg->param, DC_PARAM_FILE, file);
|
||||
dc_param_set (msg->param, DC_PARAM_MIMETYPE, filemime);
|
||||
dc_param_set_int(msg->param, DC_PARAM_DURATION, duration);
|
||||
dc_param_set (msg->param, DC_PARAM_AUTHORNAME, author);
|
||||
dc_param_set (msg->param, DC_PARAM_TRACKNAME, trackname);
|
||||
|
||||
ret = dc_send_msg(context, chat_id, msg);
|
||||
|
||||
cleanup:
|
||||
dc_msg_unref(msg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Deprecated, use dc_send_msg() instead.
|
||||
* Send a document to a chat. Use this function to send any document or file to
|
||||
* a chat.
|
||||
*
|
||||
* Sends the event #DC_EVENT_MSGS_CHANGED on succcess.
|
||||
* However, this does not imply, the message really reached the recipient -
|
||||
* sending may be delayed eg. due to network problems. However, from your
|
||||
* view, you're done with the message. Sooner or later it will find its way.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object as returned from dc_context_new().
|
||||
* @param chat_id Chat ID to send the document to.
|
||||
* @param file Full path of the file to send. The core may make a copy of the file.
|
||||
* @param filemime Mime type of the file to send. NULL if you don't know or don't care.
|
||||
* @return The ID of the message that is about being sent.
|
||||
*/
|
||||
uint32_t dc_send_file_msg(dc_context_t* context, uint32_t chat_id, const char* file, const char* filemime)
|
||||
{
|
||||
dc_msg_t* msg = dc_msg_new_untyped(context);
|
||||
uint32_t ret = 0;
|
||||
|
||||
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || chat_id<=DC_CHAT_ID_LAST_SPECIAL || file==NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
msg->type = DC_MSG_FILE;
|
||||
dc_param_set(msg->param, DC_PARAM_FILE, file);
|
||||
dc_param_set(msg->param, DC_PARAM_MIMETYPE, filemime);
|
||||
|
||||
ret = dc_send_msg(context, chat_id, msg);
|
||||
|
||||
cleanup:
|
||||
dc_msg_unref(msg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Deprecated, use dc_send_msg() instead.
|
||||
* Send foreign contact data to a chat.
|
||||
*
|
||||
* Sends the name and the email address of another contact to a chat.
|
||||
* The contact may or may not be a member of the chat.
|
||||
*
|
||||
* Typically used to share a contact to another member or to a group of members.
|
||||
*
|
||||
* Internally, the function just creates an appropriate text message and sends it
|
||||
* using dc_send_text_msg().
|
||||
*
|
||||
* NB: The "vcard" in the function name is just an abbreviation of "visiting card" and
|
||||
* is not related to the VCARD data format.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object.
|
||||
* @param chat_id The chat to send the message to.
|
||||
* @param contact_id The contact whichs data should be shared to the chat.
|
||||
* @return Returns the ID of the message sent.
|
||||
*/
|
||||
uint32_t dc_send_vcard_msg(dc_context_t* context, uint32_t chat_id, uint32_t contact_id)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
dc_msg_t* msg = dc_msg_new_untyped(context);
|
||||
dc_contact_t* contact = NULL;
|
||||
char* text_to_send = NULL;
|
||||
|
||||
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || chat_id<=DC_CHAT_ID_LAST_SPECIAL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((contact=dc_get_contact(context, contact_id))==NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (contact->authname && contact->authname[0]) {
|
||||
text_to_send = dc_mprintf("%s: %s", contact->authname, contact->addr);
|
||||
}
|
||||
else {
|
||||
text_to_send = dc_strdup(contact->addr);
|
||||
}
|
||||
|
||||
ret = dc_send_text_msg(context, chat_id, text_to_send);
|
||||
|
||||
cleanup:
|
||||
dc_msg_unref(msg);
|
||||
dc_contact_unref(contact);
|
||||
free(text_to_send);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Log a device message.
|
||||
* Such a message is typically shown in the "middle" of the chat, the user can check this using dc_msg_is_info().
|
||||
|
|
|
@ -265,12 +265,6 @@ uint32_t dc_get_chat_id_by_contact_id (dc_context_t*, uint32_t contact_id
|
|||
|
||||
uint32_t dc_send_msg (dc_context_t*, uint32_t chat_id, dc_msg_t*);
|
||||
uint32_t dc_send_text_msg (dc_context_t*, uint32_t chat_id, const char* text_to_send);
|
||||
uint32_t dc_send_image_msg (dc_context_t*, uint32_t chat_id, const char* file, const char* filemime, int width, int height);
|
||||
uint32_t dc_send_video_msg (dc_context_t*, uint32_t chat_id, const char* file, const char* filemime, int width, int height, int duration);
|
||||
uint32_t dc_send_voice_msg (dc_context_t*, uint32_t chat_id, const char* file, const char* filemime, int duration);
|
||||
uint32_t dc_send_audio_msg (dc_context_t*, uint32_t chat_id, const char* file, const char* filemime, int duration, const char* author, const char* trackname);
|
||||
uint32_t dc_send_file_msg (dc_context_t*, uint32_t chat_id, const char* file, const char* filemime);
|
||||
uint32_t dc_send_vcard_msg (dc_context_t*, uint32_t chat_id, uint32_t contact_id);
|
||||
void dc_set_text_draft (dc_context_t*, uint32_t chat_id, const char*);
|
||||
|
||||
#define DC_GCM_ADDDAYMARKER 0x01
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue