Message

Message — A message representation

Functions

Properties

char * author Read / Write / Construct
GdkRGBA * author-name-color Read / Write / Construct
TalkatuContentType content-type Read / Write / Construct Only
char * contents Read / Write / Construct
gboolean edited Read / Write / Construct
char * id Read / Write / Construct
GDateTime * timestamp Read / Write / Construct Only

Types and Values

Object Hierarchy

    GInterface
    ╰── TalkatuMessage

Known Implementations

TalkatuMessage is implemented by TalkatuInput.

Description

Talkatu needs a way to represent a message in a client agnostic way, this is the API that does that.

Functions

talkatu_message_get_id ()

gchar *
talkatu_message_get_id (TalkatuMessage *message);

Gets the identifier of the message .

Parameters

message

The TalkatuMessage instance.

 

Returns

The identifier of message .

[transfer full]

talkatu_message_set_id ()

void
talkatu_message_set_id (TalkatuMessage *message,
                        const gchar *id);

Sets the identifier of message .

Parameters

message

The TalkatuMessage instance.

 

id

The new identifier of message .

 

talkatu_message_get_timestamp ()

GDateTime *
talkatu_message_get_timestamp (TalkatuMessage *message);

Gets the timestamp for when this message was created.

Parameters

message

The TalkatuMessage instance.

 

Returns

The timestamp of message .

[transfer full][nullable]

talkatu_message_set_timestamp ()

void
talkatu_message_set_timestamp (TalkatuMessage *message,
                               GDateTime *timestamp);

Sets the creation timestamp for message to timestamp .

Parameters

message

The TalkatuMessage instance.

 

timestamp

The new timestamp for message .

[nullable]

talkatu_message_get_content_type ()

TalkatuContentType
talkatu_message_get_content_type (TalkatuMessage *message);

Gets the content-type of message .

Parameters

message

The TalkatuMessage instance.

 

Returns

The content type of message .

talkatu_message_set_content_type ()

void
talkatu_message_set_content_type (TalkatuMessage *message,
                                  TalkatuContentType content_type);

Sets the content type of message to content_type .

Parameters

message

The TalkatuMessage instance.

 

content_type

The new TalkatuContentType to set.

 

talkatu_message_get_author ()

gchar *
talkatu_message_get_author (TalkatuMessage *message);

Gets the author of message .

Parameters

message

The TalkatuMessage instance.

 

Returns

The author of message .

[transfer full]

talkatu_message_set_author ()

void
talkatu_message_set_author (TalkatuMessage *message,
                            const gchar *author);

Sets the author of message to author .

Parameters

message

The TalkatuMessage instance.

 

author

The new author of message .

 

talkatu_message_get_author_name_color ()

GdkRGBA *
talkatu_message_get_author_name_color (TalkatuMessage *message);

Gets a GdkRGBA that the author's name will be rendered with or NULL if no color is set.

Parameters

message

The TalkatuMessage instance.

 

Returns

The GdkRGBA to renderer the author's name with if set, otherwise NULL.

[transfer full]

talkatu_message_set_author_name_color ()

void
talkatu_message_set_author_name_color (TalkatuMessage *message,
                                       GdkRGBA *color);

Sets the color for the name of the author of message to color . Calling this with color set to NULL will unset a previously set color.

Parameters

message

The TalkatuMessage instance.

 

color

The new color for the author's name.

 

talkatu_message_get_contents ()

gchar *
talkatu_message_get_contents (TalkatuMessage *message);

Gets the contents of message .

Parameters

message

The TalkatuMessage instance.

 

Returns

The contents of message .

[transfer full]

talkatu_message_set_contents ()

void
talkatu_message_set_contents (TalkatuMessage *message,
                              const gchar *contents);

Sets the contents of message to contents .

Parameters

message

The TalkatuMessage instance.

 

contents

The new contents of message .

 

talkatu_message_get_edited ()

gboolean
talkatu_message_get_edited (TalkatuMessage *message);

Gets whether message has been edited by its author.

Parameters

message

The TalkatuMessage instance.

 

Returns

TRUE if message was edited by its author, or FALSE if not.

talkatu_message_set_edited ()

void
talkatu_message_set_edited (TalkatuMessage *message,
                            gboolean edited);

Sets whether message has been edited or not.

Parameters

message

The TalkatuMessage instance.

 

edited

Whether the message has been edited or not.

 

talkatu_message_add_attachment ()

gboolean
talkatu_message_add_attachment (TalkatuMessage *message,
                                TalkatuAttachment *attachment);

Adds attachment to message .

Returns TRUE if an attachment with the same ID did not already exist.

Parameters

message

The TalkatuMessage instance.

 

attachment

The TalkatuAttachment instance.

 

talkatu_message_remove_attachment ()

gboolean
talkatu_message_remove_attachment (TalkatuMessage *message,
                                   guint64 id);

Removes the TalkatuAttachment identified by id if it exists.

Parameters

message

The TalkatuMessage instance.

 

id

The id of the TalkatuAttachment

 

Returns

TRUE if the TalkatuAttachment was found and removed, FALSE otherwise.

talkatu_message_get_attachment ()

TalkatuAttachment *
talkatu_message_get_attachment (TalkatuMessage *message,
                                guint64 id);

Retrieves the TalkatuAttachment identified by id from message .

Parameters

message

The TalkatuMessage instance.

 

id

The id of the TalkatuAttachment to get.

 

Returns

The TalkatuAttachment if it was found, otherwise NULL.

[transfer full]

talkatu_message_foreach_attachment ()

void
talkatu_message_foreach_attachment (TalkatuMessage *message,
                                    TalkatuAttachmentForeachFunc func,
                                    gpointer data);

Calls func for each TalkatuAttachment that's attached to message .

Parameters

message

The TalkatuMessage instance.

 

func

The TalkatuAttachmentForeachFunc to call.

[scope call]

data

User data to pass to func .

 

talkatu_message_clear_attachments ()

void
talkatu_message_clear_attachments (TalkatuMessage *message);

Removes all attachments from message .

Parameters

message

The TalkatuMessage instance.

 

Types and Values

enum TalkatuContentType

An enum representing a given markup type.

Members

TALKATU_CONTENT_TYPE_PLAIN

Plain text content.

 

TALKATU_CONTENT_TYPE_PANGO

Pango Markup content.

 

TALKATU_CONTENT_TYPE_HTML

HTML content.

 

TALKATU_CONTENT_TYPE_MARKDOWN

Markdown content.

 

TALKATU_TYPE_MESSAGE

#define TALKATU_TYPE_MESSAGE (talkatu_message_get_type())

The standard _get_type macro for TalkatuMessage.

struct TalkatuMessageInterface

struct TalkatuMessageInterface {
	gboolean (*add_attachment)(TalkatuMessage *message, TalkatuAttachment *attachment);
	gboolean (*remove_attachment)(TalkatuMessage *message, guint64 id);
	TalkatuAttachment *(*get_attachment)(TalkatuMessage *message, guint64 id);
	void (*foreach_attachment)(TalkatuMessage *message, TalkatuAttachmentForeachFunc func, gpointer data);
	void (*clear_attachments)(TalkatuMessage *message);
};

TalkatuMessage is an interface to be implemented that standardizes the way messages are handled. All of its properties should be overridden with a sensible value returned for them.

It also needs to implement a storage mechanism for attachments which are identified by a guint64.

Members

add_attachment ()

The add_attachment vfunc is called to add an attachment to the message.

 

remove_attachment ()

The remove_attachment vfunc is called to remove an attachment from the message.

 

get_attachment ()

The get_attachment vfunc gets an attachment from the message.

 

foreach_attachment ()

The foreach_attachment vfunc is called to iterate over each attachment in the message and call the provided TalkatuForeachAttachmentFunc on them.

 

clear_attachments ()

The clear_attachments vfunc is called to clear all attachments from the message.

 

TalkatuMessage

typedef struct _TalkatuMessage TalkatuMessage;

TalkatuMessage is an opaque data structure and can only be accessed using the following functions.

Property Details

The “author” property

  “author”                   char *

The author of the message.

Owner: TalkatuMessage

Flags: Read / Write / Construct

Default value: NULL

The “author-name-color” property

  “author-name-color”        GdkRGBA *

The color to use when rendering the author's name.

Owner: TalkatuMessage

Flags: Read / Write / Construct

The “content-type” property

  “content-type”             TalkatuContentType

The content-type of the message.

Owner: TalkatuMessage

Flags: Read / Write / Construct Only

Default value: TALKATU_CONTENT_TYPE_PLAIN

The “contents” property

  “contents”                 char *

The contents of the message.

Owner: TalkatuMessage

Flags: Read / Write / Construct

Default value: NULL

The “edited” property

  “edited”                   gboolean

Whether this message has been edited by its author.

Owner: TalkatuMessage

Flags: Read / Write / Construct

Default value: FALSE

The “id” property

  “id”                       char *

The identifier of the message.

Owner: TalkatuMessage

Flags: Read / Write / Construct

Default value: NULL

The “timestamp” property

  “timestamp”                GDateTime *

The timestamp of the message.

Owner: TalkatuMessage

Flags: Read / Write / Construct Only