Truxton communication create

From truxwiki.com
Revision as of 15:02, 20 July 2021 by Sam (talk | contribs) (Created page with "This creates a communication object that you can populate with information before adding it to Truxton. Some samples of communication are email, sms, mms, chat, etc. =Syntax...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This creates a communication object that you can populate with information before adding it to Truxton.

Some samples of communication are email, sms, mms, chat, etc.

Syntax

uint64_t truxton_communication_create( uint64_t file_handle );

Parameters

file_handle

The Truxton file this communication was found.

Return value

A non-zero value on success, zero on failure.

Remarks

The parent file and media identifier will be inherited from the parent file.

Sample

#define TAG_ORIGIN_AUTOMATIC (1)
#define TAG_ORIGIN_HUMAN     (2)

void add_message( uint64_t truxton, uint64_t parent_file )
{
   char id[40];

   uint64_t communication = truxton_communication_create( parent_file );

   FILETIME now;

   GetSystemTimePreciseAsFileTime( &now );

   ULARGE_INTEGER ticks;

   ticks.LowPart = now.dwLowDateTime;
   ticks.HighPart = now.dwHighDateTime;

   truxton_communication_set_received( communication, ticks.QuadPart );
   truxton_communication_set_sent( communication, ticks.QuadPart );
   truxton_communication_set_type( communication, MESSAGE_TYPE_SMS );
   truxton_communication_set_subject( communication, "Test Message" );

   if ( truxton_communication_save( communication ) == 0 )
   {
      printf( "Failed to add child to Truxton\n" );
      truxton_communication_destroy( communication );

      return;
   }

   truxton_communication_get_id( parent_file, id, sizeof(id) );
   printf( "Saved as id %s\n", id );

   // Now that we have an id, we can add participants.

   truxton_communication_add_participant( communication, MESSAGE_PARTICIPANT_FROM, "sam@abc.xyz", NULL, 0 );
   truxton_communication_add_participant( communication, MESSAGE_PARTICIPANT_TO, "laura@abc.xyz", NULL, 0 );
   
   truxton_communication_finished( communication );

   truxton_communication_tag( communication, "Man Made", "Testing the API", TAG_ORIGIN_HUMAN );
   truxton_communication_destroy( communication );
}