Difference between revisions of "Truxton communication create"

From truxwiki.com
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This creates a communication object that you can populate with information before adding it to Truxton.
 
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.
  
Some samples of communication are email, sms, mms, chat, etc.
+
=Overview=
 +
The process of adding a communication is as follows:
 +
# Create the communication object.
 +
# Set the communication externals such as timestamps, subject, etc.
 +
# Save the object. This will create a record in the <code>[Message]</code> table and generate a [https://en.wikipedia.org/wiki/Universally_unique_identifier unique identifier] for the object.
 +
# Associate the accounts that participated in the communication.
 +
# Associate any message bodies with the communication. An example of this is a MIME message that has a plain text and [https://en.wikipedia.org/wiki/HTML HTML] message body.
 +
# Associate any attachments to the communication.
 +
# Finish the message. This will populate the <code>[NumberOfBodies]</code>, <code>[NumberOfAttachments]</code>, and <code>[ThreadID]</code> columns of the <code>[Message]</code> table.
  
 
=Syntax=
 
=Syntax=
Line 16: Line 25:
  
 
=Remarks=
 
=Remarks=
The parent file and media identifier will be inherited from the parent file.
+
The parent file and media identifier will be inherited from the <code>file_handle</code>.
  
 
=Sample=
 
=Sample=
Line 29: Line 38:
 
   uint64_t communication = truxton_communication_create( parent_file );
 
   uint64_t communication = truxton_communication_create( parent_file );
  
   FILETIME now;
+
   uint64_t message_time = truxton_parse_time( "2021-07-29 21:52:53 UTC" );
 
 
  GetSystemTimePreciseAsFileTime( &now );
 
  
  ULARGE_INTEGER ticks;
+
   truxton_communication_set_received( communication, message_time );
 
+
   truxton_communication_set_sent( communication, message_time );
  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_MIME );
 
   truxton_communication_set_type( communication, MESSAGE_TYPE_MIME );
 
   truxton_communication_set_subject( communication, "Test Message" );
 
   truxton_communication_set_subject( communication, "Test Message" );
Line 55: Line 57:
 
   // Now that we have an id, we can add participants.
 
   // Now that we have an id, we can add participants.
  
   truxton_communication_add_participant( communication, MESSAGE_PARTICIPANT_FROM, "sam@abc.xyz", NULL, 0 );
+
   if ( truxton_communication_add_participant( communication, MESSAGE_PARTICIPANT_FROM, "sam@abc.xyz", NULL, 0 ) == 0 )
   truxton_communication_add_participant( communication, MESSAGE_PARTICIPANT_TO, "laura@abc.xyz", NULL, 0 );
+
  {
 +
      printf( "Could not save FROM participant.\n" );
 +
   }
 +
 
 +
  if ( truxton_communication_add_participant( communication, MESSAGE_PARTICIPANT_TO, "laura@abc.xyz", NULL, 0 ) == 0 )
 +
  {
 +
      printf( "Could not save TO participant.\n" );
 +
  }
 +
 
 
   uint64_t message_body_1 = create_message_body_1( truxton );
 
   uint64_t message_body_1 = create_message_body_1( truxton );
 
   uint64_t message_body_2 = create_message_body_2( truxton );
 
   uint64_t message_body_2 = create_message_body_2( truxton );
Line 62: Line 72:
 
   uint64_t attachment_2 = create_attachment_2( truxton );
 
   uint64_t attachment_2 = create_attachment_2( truxton );
  
   truxton_communication_add_piece( communication, message_body_1, ORIGIN_EMAIL_BODY, 1 );
+
   if ( truxton_communication_add_piece( communication, message_body_1, ORIGIN_EMAIL_BODY, 1 ) == 0 )
   truxton_communication_add_piece( communication, message_body_1, ORIGIN_EMAIL_BODY, 2 );
+
  {
 +
      printf( "Could not add first body to message.\n" );
 +
   }
 +
 
 +
  if ( truxton_communication_add_piece( communication, message_body_1, ORIGIN_EMAIL_BODY, 2 ) == 0 )
 +
  {
 +
      printf( "Could not add second body to message.\n" );
 +
  }
  
   truxton_communication_add_piece( communication, attachment_1, ORIGIN_EMAIL_ATTACHMENT, 1 );
+
   if ( truxton_communication_add_piece( communication, attachment_1, ORIGIN_EMAIL_ATTACHMENT, 1 ) == 0 )
   truxton_communication_add_piece( communication, attachment_2, ORIGIN_EMAIL_ATTACHMENT, 2 );
+
   {
 +
      printf( "Could not add first attachment to message.\n" );
 +
  }
  
   truxton_communication_finished( communication );
+
   if ( truxton_communication_add_piece( communication, attachment_2, ORIGIN_EMAIL_ATTACHMENT, 2 ) == 0 )
 +
  {
 +
      printf( "Could not add second attachment to message.\n" );
 +
  }
 +
 
 +
  if ( truxton_communication_finished( communication ) == 0 )
 +
  {
 +
      printf( "Could not complete message record.\n" );
 +
  }
 +
 
 +
  if ( truxton_communication_tag( communication, "Man Made", "Testing the API", TAG_ORIGIN_HUMAN ) == 0 )
 +
  {
 +
      printf( "Could not tag message.\n" );
 +
  }
  
  truxton_communication_tag( communication, "Man Made", "Testing the API", TAG_ORIGIN_HUMAN );
 
 
   truxton_communication_destroy( communication );
 
   truxton_communication_destroy( communication );
 
}
 
}
 
</source>
 
</source>

Latest revision as of 05:24, 1 November 2022

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.

Overview

The process of adding a communication is as follows:

  1. Create the communication object.
  2. Set the communication externals such as timestamps, subject, etc.
  3. Save the object. This will create a record in the [Message] table and generate a unique identifier for the object.
  4. Associate the accounts that participated in the communication.
  5. Associate any message bodies with the communication. An example of this is a MIME message that has a plain text and HTML message body.
  6. Associate any attachments to the communication.
  7. Finish the message. This will populate the [NumberOfBodies], [NumberOfAttachments], and [ThreadID] columns of the [Message] table.

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 file_handle.

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 );

   uint64_t message_time = truxton_parse_time( "2021-07-29 21:52:53 UTC" );

   truxton_communication_set_received( communication, message_time );
   truxton_communication_set_sent( communication, message_time );
   truxton_communication_set_type( communication, MESSAGE_TYPE_MIME );
   truxton_communication_set_subject( communication, "Test Message" );

   if ( truxton_communication_save( communication ) == 0 )
   {
      printf( "Failed to add communication 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.

   if ( truxton_communication_add_participant( communication, MESSAGE_PARTICIPANT_FROM, "sam@abc.xyz", NULL, 0 ) == 0 )
   {
      printf( "Could not save FROM participant.\n" );
   }

   if ( truxton_communication_add_participant( communication, MESSAGE_PARTICIPANT_TO, "laura@abc.xyz", NULL, 0 ) == 0 )
   {
      printf( "Could not save TO participant.\n" );
   }

   uint64_t message_body_1 = create_message_body_1( truxton );
   uint64_t message_body_2 = create_message_body_2( truxton );
   uint64_t attachment_1 = create_attachment_1( truxton );
   uint64_t attachment_2 = create_attachment_2( truxton );

   if ( truxton_communication_add_piece( communication, message_body_1, ORIGIN_EMAIL_BODY, 1 ) == 0 )
   {
      printf( "Could not add first body to message.\n" );
   }

   if ( truxton_communication_add_piece( communication, message_body_1, ORIGIN_EMAIL_BODY, 2 ) == 0 )
   {
      printf( "Could not add second body to message.\n" );
   }

   if ( truxton_communication_add_piece( communication, attachment_1, ORIGIN_EMAIL_ATTACHMENT, 1 ) == 0 )
   {
      printf( "Could not add first attachment to message.\n" );
   }

   if ( truxton_communication_add_piece( communication, attachment_2, ORIGIN_EMAIL_ATTACHMENT, 2 ) == 0 )
   {
      printf( "Could not add second attachment to message.\n" );
   }

   if ( truxton_communication_finished( communication ) == 0 )
   {
      printf( "Could not complete message record.\n" );
   }

   if ( truxton_communication_tag( communication, "Man Made", "Testing the API", TAG_ORIGIN_HUMAN ) == 0 )
   {
      printf( "Could not tag message.\n" );
   }

   truxton_communication_destroy( communication );
}