Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
TermsAndConditions Class Reference

#include <TermsAndConditions.hpp>

Collaboration diagram for TermsAndConditions:

Public Member Functions

 TermsAndConditions (UINT8 *id, UINT32 nrOfTranslations)
 Constructor with the id (Operator SKI), the number of translations and those elements to be imported to all translations. More...
 
virtual ~TermsAndConditions ()
 
const termsAndConditionsTranslation_tgetTranslation (const UINT8 *locale)
 returns the specific TermsAndconditions translation for the the language with the specified language code including the template AND the customized sections. More...
 
const DOMNode * getTranslationTemplate (const UINT8 *locale)
 returns only the template of the translation specified by the language code or NULL if no such translation exist. More...
 
const DOMNode * getTranslationCustomizedSections (const UINT8 *locale)
 returns only the customized sections of the translation specified by the language code or NULL if no such translation exist. More...
 
void removeTranslation (const UINT8 *locale)
 removes the specific Terms & Conditions translation for the the language with the specified language code including the template AND the customized sections. More...
 
void addTranslation (const UINT8 *locale, DOMNode *tnc_customized, DOMNode *tnc_template)
 add a language specific terms and Conditions document, which can be retrieved by *getTermsAndConditionsDoc with the language code More...
 
const UINT8getID ()
 

Public Attributes

CAMutexsynchLock
 

Private Member Functions

void setIndexToNextEmptySlot ()
 

Private Attributes

UINT8tnc_id
 
UINT32 translations
 
UINT32 currentTranslationIndex
 
termsAndConditionsTranslation_t ** allTranslations
 
XERCES_CPP_NAMESPACE::DOMDocument * customizedSectionsOwner
 

Detailed Description

Definition at line 61 of file TermsAndConditions.hpp.

Constructor & Destructor Documentation

◆ TermsAndConditions()

TermsAndConditions::TermsAndConditions ( UINT8 id,
UINT32  nrOfTranslations 
)

Constructor with the id (Operator SKI), the number of translations and those elements to be imported to all translations.

Constructor with the id (Operator SKI) and the number of translations.

Definition at line 76 of file TermsAndConditions.cpp.

77 {
79  /* The id of the Terms & Conditions is the operator ski. */
80  if(id != NULL)
81  {
82  size_t idlen = strlen((char *) id);
83  tnc_id = new UINT8[idlen+1];
84  memset(tnc_id, 0, (idlen+1));
85  memcpy(tnc_id, id, idlen);
86  }
87  else
88  {
89  tnc_id = NULL;
90  }
91 
92  translations = (nrOfTranslations == 0) ? 1 : nrOfTranslations;
95  for (UINT32 i = 0; i < translations; i++)
96  {
97  allTranslations[i] = NULL;
98  }
99  synchLock = new CAMutex();
100 }
XERCES_CPP_NAMESPACE::DOMDocument * createDOMDocument()
Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in...
Definition: CAUtil.cpp:1568
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
XERCES_CPP_NAMESPACE::DOMDocument * customizedSectionsOwner
termsAndConditionsTranslation_t ** allTranslations

References allTranslations, createDOMDocument(), currentTranslationIndex, customizedSectionsOwner, synchLock, tnc_id, and translations.

Here is the call graph for this function:

◆ ~TermsAndConditions()

TermsAndConditions::~TermsAndConditions ( )
virtual

Definition at line 102 of file TermsAndConditions.cpp.

103 {
104  delete synchLock;
105  synchLock = NULL;
106  for (UINT32 i = 0; i < translations; i++)
107  {
108  if(allTranslations[i] != NULL)
109  {
111  delete allTranslations[i];
112  allTranslations[i] = NULL;
113  }
114  }
115  delete [] allTranslations;
116  allTranslations = NULL;
117  delete [] tnc_id;
118  tnc_id = NULL;
119  translations = 0;
121  customizedSectionsOwner->release();
123 }
void cleanupTnCTranslation(termsAndConditionsTranslation_t *tnCTranslation)

References allTranslations, cleanupTnCTranslation(), currentTranslationIndex, customizedSectionsOwner, synchLock, tnc_id, and translations.

Here is the call graph for this function:

Member Function Documentation

◆ addTranslation()

void TermsAndConditions::addTranslation ( const UINT8 locale,
DOMNode *  tnc_customized,
DOMNode *  tnc_template 
)

add a language specific terms and Conditions document, which can be retrieved by *getTermsAndConditionsDoc with the language code

Definition at line 183 of file TermsAndConditions.cpp.

184 {
185  if(locale == NULL)
186  {
187  return;
188  }
190  if(newEntry == NULL)
191  {
192  newEntry = new termsAndConditionsTranslation_t;
193  //import the customized sections to the internal T & C document to ensure it is not
194  //released by it's former owner document.
195  newEntry->tnc_customized = customizedSectionsOwner->importNode(tnc_customized, true);
196  newEntry->tnc_template = tnc_template;
197  newEntry->tnc_id = tnc_id;
198  newEntry->tnc_locale = new UINT8[TMP_LOCALE_SIZE];
199  memset(newEntry->tnc_locale, 0, TMP_LOCALE_SIZE);
200  memcpy(newEntry->tnc_locale, locale, TMP_LOCALE_SIZE);
201 
203  {
204  //allocate new storage space.
206  memset(newAllocatedSpace, 0, (sizeof(termsAndConditionsTranslation_t *)*(translations+RESIZE_STORE)) );
207  memcpy(newAllocatedSpace, allTranslations,
209  delete [] allTranslations;
210  allTranslations = newAllocatedSpace;
212  }
214  CAMsg::printMsg(LOG_DEBUG,"Adding translation [%s] for t&c %s to index %u\n", newEntry->tnc_locale, newEntry->tnc_id, currentTranslationIndex);
216  }
217  else
218  {
219  newEntry->tnc_customized->release();
220  //same as above: avoid release by the former owner document of this node.
221  newEntry->tnc_customized = customizedSectionsOwner->importNode(tnc_customized, true);
222  newEntry->tnc_template = tnc_template;
223  }
224 }
#define TMP_LOCALE_SIZE
Definition: CAUtil.hpp:39
#define RESIZE_STORE
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
const termsAndConditionsTranslation_t * getTranslation(const UINT8 *locale)
returns the specific TermsAndconditions translation for the the language with the specified language ...

References allTranslations, currentTranslationIndex, customizedSectionsOwner, getTranslation(), CAMsg::printMsg(), RESIZE_STORE, setIndexToNextEmptySlot(), TMP_LOCALE_SIZE, termsAndConditionsTranslation_t::tnc_customized, termsAndConditionsTranslation_t::tnc_id, tnc_id, termsAndConditionsTranslation_t::tnc_locale, termsAndConditionsTranslation_t::tnc_template, and translations.

Referenced by CAFirstMix::handleTermsAndConditionsExtension().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getID()

const UINT8 * TermsAndConditions::getID ( )

Definition at line 248 of file TermsAndConditions.cpp.

249 {
250  return (const UINT8 *) tnc_id;
251 }

References tnc_id.

◆ getTranslation()

const termsAndConditionsTranslation_t * TermsAndConditions::getTranslation ( const UINT8 locale)

returns the specific TermsAndconditions translation for the the language with the specified language code including the template AND the customized sections.

If no translation exists for the specified language code NULL is returned.

Definition at line 130 of file TermsAndConditions.cpp.

131 {
132  if(locale == NULL)
133  {
134  return NULL;
135  }
136  const termsAndConditionsTranslation_t *foundEntry = NULL;
137  for (UINT32 i = 0; i < translations; i++)
138  {
139  if(allTranslations[i] != NULL)
140  {
141  if( strncasecmp((const char *) locale, (char *) allTranslations[i]->tnc_locale, 2) == 0 )
142  {
143  foundEntry = allTranslations[i];
144  break;
145  }
146  }
147  }
148  return (const termsAndConditionsTranslation_t *) foundEntry;
149 }

References allTranslations, and translations.

Referenced by addTranslation(), getTranslationCustomizedSections(), getTranslationTemplate(), and CAFirstMix::handleTermsAndConditionsLogin().

Here is the caller graph for this function:

◆ getTranslationCustomizedSections()

const DOMNode * TermsAndConditions::getTranslationCustomizedSections ( const UINT8 locale)

returns only the customized sections of the translation specified by the language code or NULL if no such translation exist.

Definition at line 169 of file TermsAndConditions.cpp.

170 {
171  const termsAndConditionsTranslation_t *foundEntry = getTranslation(locale);
172  if(foundEntry != NULL)
173  {
174  return (const DOMNode *) foundEntry->tnc_customized;
175  }
176  return NULL;
177 }

References getTranslation(), and termsAndConditionsTranslation_t::tnc_customized.

Here is the call graph for this function:

◆ getTranslationTemplate()

const DOMNode * TermsAndConditions::getTranslationTemplate ( const UINT8 locale)

returns only the template of the translation specified by the language code or NULL if no such translation exist.

Definition at line 155 of file TermsAndConditions.cpp.

156 {
157  const termsAndConditionsTranslation_t *foundEntry = getTranslation(locale);
158  if(foundEntry != NULL)
159  {
160  return foundEntry->tnc_template;
161  }
162  return NULL;
163 }

References getTranslation(), and termsAndConditionsTranslation_t::tnc_template.

Here is the call graph for this function:

◆ removeTranslation()

void TermsAndConditions::removeTranslation ( const UINT8 locale)

removes the specific Terms & Conditions translation for the the language with the specified language code including the template AND the customized sections.

Definition at line 230 of file TermsAndConditions.cpp.

231 {
232  for (UINT32 i = 0; i < translations; i++)
233  {
234  if(allTranslations[i] != NULL)
235  {
236  if( strncasecmp((const char *) locale, (char *) allTranslations[i]->tnc_locale, 2) == 0 )
237  {
239  delete allTranslations[i];
240  allTranslations[i] = NULL;
241  break;
242  }
243  }
244  }
246 }

References allTranslations, cleanupTnCTranslation(), setIndexToNextEmptySlot(), and translations.

Here is the call graph for this function:

◆ setIndexToNextEmptySlot()

void TermsAndConditions::setIndexToNextEmptySlot ( )
private

Definition at line 254 of file TermsAndConditions.cpp.

255 {
256  for (UINT32 i = 0; i < translations; i++)
257  {
258  if(allTranslations[i] == NULL)
259  {
261  return;
262  }
263  }
264  /* Nothing is free */
266 }

References allTranslations, currentTranslationIndex, and translations.

Referenced by addTranslation(), and removeTranslation().

Here is the caller graph for this function:

Member Data Documentation

◆ allTranslations

termsAndConditionsTranslation_t** TermsAndConditions::allTranslations
private

◆ currentTranslationIndex

UINT32 TermsAndConditions::currentTranslationIndex
private

◆ customizedSectionsOwner

XERCES_CPP_NAMESPACE::DOMDocument* TermsAndConditions::customizedSectionsOwner
private

Definition at line 76 of file TermsAndConditions.hpp.

Referenced by addTranslation(), TermsAndConditions(), and ~TermsAndConditions().

◆ synchLock

CAMutex* TermsAndConditions::synchLock

Definition at line 83 of file TermsAndConditions.hpp.

Referenced by TermsAndConditions(), and ~TermsAndConditions().

◆ tnc_id

UINT8* TermsAndConditions::tnc_id
private

◆ translations

UINT32 TermsAndConditions::translations
private

The documentation for this class was generated from the following files: