# SkypeKit Class Properties

Each SkypeKit class has a special enumerator, named PROPERTY, that contains the list of property IDs for that class. All the PROPERTY items are prefixed with "P_".

While most SkypeKit class properties are read-only, read-write properties have a special class method for setting their value. For example, Conversation::P_META_TOPIC property can be set with Conversation::SetTopic method.

However, there is an exception to this - Account class. Many Account class properties are read-write and have two sets of type-specific setter methods. One set operates on server side properties that are synced to cloud immediately and the other set operates on account profile properties that are synced to cloud periodically using the CBL synchronization mechanism.

Class properties are cached in the wrapper. Once you have accessed an object property or it has received an update message from the runtime - no additional IPC traffic is generated and the property access should be rather fast. Once cached, that property will be kept up-to-date automatically.

Read access to class properties is provided in three different ways.

## GetProp - get property as a string

The most generic way to get a SkypeKit class property is GetProp method. It takes property ID as an argument and returns a SEString. If the actual property type is something else, for example int - the value is converted to SEString before passing it on to you.

    SEString DisplayName;
    DisplayName = SomeConversation->GetProp(Conversation::P_DISPLAYNAME);

NB! In case of enum values, GetProp will not convert these into human readable names. Instead, the numeric enum value is returned as a string (1 -> "1").

## GetPropPropName - strongly typed accessor

Each class property also has a corresponding strongly typed accessor method. Those methods are prefixed with GetProp followed by the property name.

    Account::STATUS LoginStatus;
    GetPropStatus(LoginStatus);

## GetProps - get multiple properties all at once

If you need to access multiple properties, you can get those with GetProps method where you can pass in a list of property IDs and get back a dictionary with property IDs and their values (as SEStrings). While this is more code on your side, the advantage here is that the entire request/response goes through IPC more effectively, resulting in improved performance.

    SEIntList Props;
    SEIntDict Values;
    Props.append(Conversation::P_TYPE);
    Props.append(Conversation::P_DISPLAYNAME);

    ConversationRefs Inbox = ConversationRefs();
    skype->GetConversationList(Inbox, Conversation::INBOX_CONVERSATIONS);
    int InboxSize = Inbox.size();

    SEString    Type        = "";
    SEString    DisplayName = "";

    printf("Conversations in Inbox : %d\n", InboxSize);

    for (int i = 0; i < InboxSize; i++)
    {
        C = (ConversationRef)Inbox[i];
        Values      = C->GetProps(Props);
        Type        = Values.find(Conversation::P_TYPE);
        DisplayName = Values.find(Conversation::P_DISPLAYNAME);
        printf("Type: %s  Name: %s \n", (const char*)Type, (const char*)DisplayName);
    };

## Properties and debug output

While developing and testing, you will often come accross situations where you want to log SkypeKit object properties in your debug output. The problem there is that most of those properties are typed as enumerated values. For example, if Account::P_STATUS becomes 1, your log would look prettier if that 1 is represented as "LOGGED_OUT".

So, what you will want to do is to convert those values to human readable strings. The GetProp method that returns a string is of no help - it only converts the value to a string (i.e. 1 will come out as "1"), it does not return you the appropriate enum item name, based on its type.

Luckily, there is not one but two ways of converting enumerator items into strings.

First the tostring function. It takes one argument - any SkypeKit enumerator value will do, and return a string, consisting of the class name, property name and property value label. The following way of logging Account::P_STATUS property:

    void MyAccount::OnChange(int prop)
    {
      if (prop == Account::P_STATUS)
      {
        Account::STATUS loginStatus;
        this->GetPropStatus(loginStatus);
        printf("%s\n", (const char*)tostring(loginStatus));
      };
    };

..would (in case of successful login) produce this output:

    Account::STATUS.CONNECTING_TO_P2P
    Account::STATUS.CONNECTING_TO_SERVER
    Account::STATUS.LOGGING_IN
    Account::STATUS.INITIALIZING
    Account::STATUS.LOGGED_IN

Another way to do this is via SEObject::getPropDebug method. This method takes two arguments: property ID and property value as string and returns an SEStringList with three items: class name, property name and property value.

    void MyAccount::OnChange(int prop)
    {
      if (prop == Account::P_STATUS)
      {
        SEStringList dbg;
        SEString propStr = this->GetProp(prop);
        dbg = this->getPropDebug(prop, propStr);
        printf("%s object %s property is now %s \n", (const char*)dbg[0], (const char*)dbg[1], (const char*)dbg[2]);
      };
    };

Would produce following output:

    ACCOUNT object STATUS property is now CONNECTING_TO_P2P
    ACCOUNT object STATUS property is now CONNECTING_TO_SERVER
    ACCOUNT object STATUS property is now LOGGING_IN
    ACCOUNT object STATUS property is now INITIALIZING
    ACCOUNT object STATUS property is now LOGGED_IN

The advantage here is that you don't need to know what particular property you are dealing with. For tostring to work, you need to declare a typed local variable (like in these examples: Account::STATUS loginStatus) and fetch the value, to pass it to the tostring function. Because of that, in your OnChange callback method, you would need to have the debug output code separately for each property. The getPropDebug method is proprty-agnostic. You can have the above sample outside the if (prop == Account::P_STATUS) statement, in which case it would produce output for all Account property changes.

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

(c) Skype Technologies S.A. Confidential/Proprietary

Last updated: Fri Jan 27 2012