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

#include <TermsAndConditions.hpp>

Collaboration diagram for TermsAndConditions:
[legend]

List of all members.

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.
virtual ~TermsAndConditions ()
const
termsAndConditionsTranslation_t
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.
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.
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.
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.
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
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 ( 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 74 of file TermsAndConditions.cpp.

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

{
  customizedSectionsOwner = createDOMDocument();
  /* The id of the Terms & Conditions is the operator ski. */
  if(id != NULL)
  {
    size_t idlen = strlen((char *) id);
    tnc_id = new UINT8[idlen+1];
    memset(tnc_id, 0, (idlen+1));
    memcpy(tnc_id, id, idlen);
  }
  else
  {
    tnc_id = NULL;
  }

  translations = (nrOfTranslations == 0) ? 1 : nrOfTranslations;
  currentTranslationIndex = 0;
  allTranslations = new termsAndConditionsTranslation_t *[translations];
  for (UINT32 i = 0; i < translations; i++)
  {
    allTranslations[i] = NULL;
  }
  synchLock = new CAMutex();
}

Here is the call graph for this function:

Definition at line 100 of file TermsAndConditions.cpp.

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

{
  delete synchLock;
  synchLock = NULL;
  for (UINT32 i = 0; i < translations; i++)
  {
    if(allTranslations[i] != NULL)
    {
      cleanupTnCTranslation(allTranslations[i]);
      delete allTranslations[i];
      allTranslations[i] = NULL;
    }
  }
  delete [] allTranslations;
  allTranslations = NULL;
  delete [] tnc_id;
  tnc_id = NULL;
  translations =  0;
  currentTranslationIndex = 0;
  customizedSectionsOwner->release();
  customizedSectionsOwner = NULL;
}

Here is the call graph for this function:


Member Function Documentation

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 181 of file TermsAndConditions.cpp.

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().

{
  if(locale == NULL)
  {
    return;
  }
  termsAndConditionsTranslation_t *newEntry = (termsAndConditionsTranslation_t *) getTranslation(locale);
  if(newEntry == NULL)
  {
    newEntry = new termsAndConditionsTranslation_t;
    //import the customized sections to the internal T & C document to ensure it is not
    //released by it's former owner document.
    newEntry->tnc_customized = customizedSectionsOwner->importNode(tnc_customized, true);
    newEntry->tnc_template = tnc_template;
    newEntry->tnc_id = tnc_id;
    newEntry->tnc_locale = new UINT8[TMP_LOCALE_SIZE];
    memset(newEntry->tnc_locale, 0, TMP_LOCALE_SIZE);
    memcpy(newEntry->tnc_locale, locale, TMP_LOCALE_SIZE);

    if(currentTranslationIndex == translations)
    {
      //allocate new storage space.
      termsAndConditionsTranslation_t **newAllocatedSpace = new termsAndConditionsTranslation_t *[translations+RESIZE_STORE];
      memset(newAllocatedSpace, 0, (sizeof(termsAndConditionsTranslation_t *)*(translations+RESIZE_STORE)) );
      memcpy(newAllocatedSpace, allTranslations,
          (sizeof(termsAndConditionsTranslation_t *)*translations) );
      delete [] allTranslations;
      allTranslations = newAllocatedSpace;
      translations += RESIZE_STORE;
    }
    allTranslations[currentTranslationIndex] = newEntry;
    CAMsg::printMsg(LOG_DEBUG,"Adding translation [%s] for t&c %s to index %u\n", newEntry->tnc_locale, newEntry->tnc_id, currentTranslationIndex);
    setIndexToNextEmptySlot();
  }
  else
  {
    newEntry->tnc_customized->release();
    //same as above: avoid release by the former owner document of this node.
    newEntry->tnc_customized = customizedSectionsOwner->importNode(tnc_customized, true);
    newEntry->tnc_template = tnc_template;
  }
}

Here is the call graph for this function:

Definition at line 246 of file TermsAndConditions.cpp.

References tnc_id.

{
  return (const UINT8 *)  tnc_id;
}

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 128 of file TermsAndConditions.cpp.

References allTranslations, and translations.

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

{
  if(locale == NULL)
  {
    return NULL;
  }
  const termsAndConditionsTranslation_t *foundEntry = NULL;
  for (UINT32 i = 0; i < translations; i++)
  {
    if(allTranslations[i] != NULL)
    {
      if( strncasecmp((const char *) locale, (char *) allTranslations[i]->tnc_locale, 2) == 0 )
      {
        foundEntry = allTranslations[i];
        break;
      }
    }
  }
  return (const termsAndConditionsTranslation_t *) foundEntry;
}
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 167 of file TermsAndConditions.cpp.

References getTranslation(), and termsAndConditionsTranslation_t::tnc_customized.

{
  const termsAndConditionsTranslation_t *foundEntry = getTranslation(locale);
  if(foundEntry != NULL)
  {
    return (const DOMNode *) foundEntry->tnc_customized;
  }
  return NULL;
}

Here is the call graph for this function:

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 153 of file TermsAndConditions.cpp.

References getTranslation(), and termsAndConditionsTranslation_t::tnc_template.

{
  const termsAndConditionsTranslation_t *foundEntry = getTranslation(locale);
  if(foundEntry != NULL)
  {
    return foundEntry->tnc_template;
  }
  return NULL;
}

Here is the call graph for this function:

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 228 of file TermsAndConditions.cpp.

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

{
  for (UINT32 i = 0; i < translations; i++)
  {
    if(allTranslations[i] != NULL)
    {
      if( strncasecmp((const char *) locale, (char *) allTranslations[i]->tnc_locale, 2) == 0 )
      {
        cleanupTnCTranslation(allTranslations[i]);
        delete allTranslations[i];
        allTranslations[i] = NULL;
        break;
      }
    }
  }
  setIndexToNextEmptySlot();
}

Here is the call graph for this function:

Definition at line 252 of file TermsAndConditions.cpp.

References allTranslations, currentTranslationIndex, and translations.

Referenced by addTranslation(), and removeTranslation().

{
  for (UINT32 i = 0; i < translations; i++)
  {
    if(allTranslations[i] == NULL)
    {
      currentTranslationIndex = i;
      return;
    }
  }
  /* Nothing is free */
  currentTranslationIndex = translations;
}

Member Data Documentation

XERCES_CPP_NAMESPACE::DOMDocument* TermsAndConditions::customizedSectionsOwner [private]

Definition at line 76 of file TermsAndConditions.hpp.

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

Definition at line 83 of file TermsAndConditions.hpp.

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


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