Hello,
It is me again.
I have some troubles with PHOTO for synchronised contact.
I used the same idea to extract encoded value to decode it.
I tried with GetValue and  GetValueByID but no chance.
Any idea to get it and encoding type also.
Thanks for help guys.


Regards

2011/9/19 Roger KeIrad <roger.kil...@gmail.com>

> Thanks Lukas.
>
> 2011/9/16 Lukas Zeller <l...@plan44.ch>
>
>> Hello Roger,
>>
>> On Sep 16, 2011, at 16:28 , Roger KeIrad wrote:
>>
>> > hello,
>> > any help please?
>> > thanks in advance.
>>
>>
>> There are a number of GetValueXXX variants. GetValue() is only for single
>> values.
>>
>> For arrays, you need to use GetValueByID(), which has a arrIndex
>> parameter. To get the ID for a name, use GetValueID(). You can get the size
>> of the array by appending VALSUFF_ARRSZ to the array field name, and call
>> GetValue() with that - you'll get the number of elements back.
>>
>> See sysync_SDK/Sources/enginemodulebase.h for more detailed description of
>> all the Get/SetValue functions, and engine_defs.h for the VALNAME_xxx and
>> VALSUFF_xxx explanations.
>>
>> Pseudo code to get all elements of an array would look like:
>> SDK_InterfaceType
>>
>> // get size of array
>> uInt16 arraySize;
>> memsize n;
>> GetValue("arrayFieldName" VALSUFF_ARRSZ, VALTYPE_INT16,
>> &arraySize,sizeof(arraySize),n);
>>
>> // get elements of array
>> long arrayFieldID = GetValueID("arrayFieldName");
>> for (int i=0; i<arraySize; i++) {
>>  GetValueByID(arrayFieldID, i, VALTYPE_XXX, &buffer, maxSize, n);
>>  // do something with the value
>> }
>>
>>
>>
>> Below is a more elaborate routine, which prints out all values for a given
>> aItemKey, including array fields:
>>
>>
>> /* Show all fields/variables of item represented by aItemKey */
>> static void ShowFields(DB_Callback cb, appPointer aItemKey)
>> {
>>  const stringSize maxstr = 128;
>>  appChar fnam[maxstr];
>>  appChar fval[maxstr];
>>  appChar ftz[maxstr];
>>  uInt16 fvaltype;
>>  uInt16 farrsize;
>>  uInt16 arridx;
>>  bool fisarray;
>>  uInt32 valsize;
>>  TSyError err;
>>  uInt32 valueID,nameFlag,typeFlag,arrszFlag,tznamFlag;
>>  // set desired time mode
>>  cb->ui.SetTimeMode(cb, aItemKey, TMODE_LINEARTIME+TMODE_FLAG_FLOATING);
>>  // get flags that can be combined with valueID to get attributes of a
>> value
>>  nameFlag = cb->ui.GetValueID(cb, aItemKey, ".FLAG.VALNAME");
>>  typeFlag = cb->ui.GetValueID(cb, aItemKey, ".FLAG.VALTYPE");
>>  arrszFlag = cb->ui.GetValueID(cb, aItemKey, ".FLAG.ARRAYSIZE");
>>  tznamFlag = cb->ui.GetValueID(cb, aItemKey, ".FLAG.TZNAME");
>>  // iterate over all fields
>>  // - start iteration
>>  valueID = cb->ui.GetValueID(cb, aItemKey, VALNAME_FIRST);
>>  while (valueID != KEYVAL_ID_UNKNOWN && valueID != KEYVAL_NO_ID) {
>>    // get field name
>>    err = cb->ui.GetValueByID(cb,
>>      aItemKey,
>>      valueID + nameFlag,
>>      0,
>>      VALTYPE_TEXT,
>>      fnam,
>>      maxstr,
>>      &valsize
>>    );
>>    // get field type
>>    err = cb->ui.GetValueByID(cb,
>>      aItemKey,
>>      valueID + typeFlag,
>>      0,
>>      VALTYPE_INT16,
>>      &fvaltype,
>>      sizeof(fvaltype),
>>      &valsize
>>    );
>>    // check if array, and if array, get number of elements
>>    err = cb->ui.GetValueByID(cb,
>>      aItemKey,
>>      valueID + arrszFlag,
>>      0,
>>      VALTYPE_INT16,
>>      &farrsize,
>>      sizeof(farrsize),
>>      &valsize
>>    );
>>    fisarray = err==LOCERR_OK;
>>
>>    if (!fisarray) {
>>      // single value
>>      err = cb->ui.GetValueByID(cb, aItemKey, valueID, 0, VALTYPE_TEXT,
>> fval, maxstr, &valsize);
>>      if (err==LOCERR_OK) {
>>        if (fvaltype==VALTYPE_TIME64) {
>>          // for timestamps, get time zone name as well
>>          cb->ui.GetValueByID(cb, aItemKey, valueID+tznamFlag, 0,
>> VALTYPE_TEXT, ftz, maxstr, &valsize);
>>          DEBUG_(cb, "- %-20s (VALTYPE=%2hd) = %s
>> timezone=%s",fnam,fvaltype,fval,ftz);
>>        }
>>        else
>>          DEBUG_(cb, "- %-20s (VALTYPE=%2hd) = '%s'",fnam,fvaltype,fval);
>>      }
>>      else
>>        DEBUG_(cb, "- %-20s (VALTYPE=%2hd) : No value,
>> error=%hd",fnam,fvaltype,err);
>>    }
>>    else {
>>      // array
>>      DEBUG_(cb, "- %-20s (VALTYPE=%2d) = Array with %d
>> elements",fnam,fvaltype,farrsize);
>>      // show elements
>>      for (arridx=0; arridx<farrsize; arridx++) {
>>        err = cb->ui.GetValueByID(cb, aItemKey, valueID, arridx,
>> VALTYPE_TEXT, fval, maxstr, &valsize);
>>        if (err==LOCERR_OK) {
>>          if (fvaltype==VALTYPE_TIME64) {
>>            // for timestamps, get time zone name as well
>>            cb->ui.GetValueByID(cb, aItemKey, valueID+tznamFlag, arridx,
>> VALTYPE_TEXT, ftz, maxstr, &valsize);
>>            DEBUG_(cb, "           %20s[%3hd] = %s
>> timezone=%s",fnam,arridx,fval,ftz);
>>          }
>>          else
>>            DEBUG_(cb, "           %20s[%3hd] = '%s'",fnam,arridx,fval);
>>        }
>>        else
>>          DEBUG_(cb, "           %20s[%3hd] : No value,
>> error=%hd",fnam,arridx,err);
>>      }
>>    }
>>    // next value
>>    valueID = cb->ui.GetValueID(cb, aItemKey, VALNAME_NEXT);
>>  } // while more values
>> } /* ShowFields */
>>
>>
>
_______________________________________________
os-libsynthesis mailing list
os-libsynthesis@synthesis.ch
http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis

Reply via email to