コード例 #1
0
ファイル: azy_content_json.c プロジェクト: gfriloux/maelstrom
static cJSON *
azy_value_serialize_basic_json(const Eina_Value *val)
{
   switch (azy_value_util_type_get(val))
     {
      case AZY_VALUE_INT:
        {
           int int_val = -1;
           eina_value_get(val, &int_val);
           return cJSON_CreateNumber(int_val);
        }

      case AZY_VALUE_TIME:
        {
           time_t t;
           struct tm *tim;
           char buf[1024];

           eina_value_get(val, &t);
           tim = localtime(&t);
           strftime(buf, sizeof(buf), "%Y%m%dT%H:%M:%S", tim);
           return cJSON_CreateString(buf);
        }

      case AZY_VALUE_STRING:
      case AZY_VALUE_BASE64:
        {
           const char *str_val;
           eina_value_get(val, &str_val);
           return cJSON_CreateString(str_val);
        }

      case AZY_VALUE_BOOL:
        {
           Eina_Bool bool_val;
           eina_value_get(val, &bool_val);

           if (bool_val)
             return cJSON_CreateTrue();

           return cJSON_CreateFalse();
        }

      case AZY_VALUE_DOUBLE:
        {
           double dbl_val = -1;
           eina_value_get(val, &dbl_val);
           return cJSON_CreateNumber(dbl_val);
        }
      default: break;
     }

   return NULL;
}
コード例 #2
0
ファイル: azy_content_json.c プロジェクト: gfriloux/maelstrom
static Eina_Value *
azy_value_deserialize_array_json(cJSON *object)
{
   Eina_Value *arr;
   const Eina_Value_Type *type;
   int x = 0;
   cJSON *child;

   child = cJSON_GetArrayItem(object, 0);
   if (!child)
     return eina_value_array_new(EINA_VALUE_TYPE_STRING, 0);

   type = _azy_value_type_get(child);
   arr = eina_value_array_new(type, 0);
   for (; x < cJSON_GetArraySize(object); x++)
     {
        if (x)
          {
             child = cJSON_GetArrayItem(object, x);
             if(_azy_value_type_get(child) != type)
               {
                  EINA_LOG_ERR("We have different type of data in array.");
                  continue;
               }
          }
        if (type == EINA_VALUE_TYPE_ARRAY)
          {
             Eina_Value_Array inner_array;
             Eina_Value *data = azy_value_deserialize_array_json(child);
             if (!data) goto error;
             eina_value_get(data, &inner_array);
             eina_value_array_append(arr, inner_array);
          }
        else if (type == EINA_VALUE_TYPE_STRUCT)
          {
             Eina_Value_Struct st;
             Eina_Value *data = azy_value_deserialize_struct_json(child);
             if (!data) goto error;
             eina_value_get(data, &st);
             eina_value_array_append(arr, st);
          }
        else
          {
             if (!azy_value_deserialize_basic_json(child, arr)) goto error;
          }
     }
   return arr;
error:
   eina_value_free(arr);
   return NULL;
}
コード例 #3
0
static void
_fill_receive_array_of_string_int_with_size(Eldbus_Message *msg, int size, const char *array[])
{
   Eina_Value *value_struct, *value_array;
   int i;
   unsigned offset;
   Eina_Value_Struct_Member main_members[2];
   Eina_Value_Struct_Member sub_members[] = {
      EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_STRING, sub_struct, txt),
      EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, sub_struct, num)
   };
   Eina_Value_Struct_Desc desc_sub_struct = {
      EINA_VALUE_STRUCT_DESC_VERSION,
      NULL, // no special operations
      sub_members,
      2,
      sizeof(sub_struct)
   };
   Eina_Value_Struct_Desc desc_struct = {
      EINA_VALUE_STRUCT_DESC_VERSION,
      NULL, // no special operations
      main_members,
      2,
      0//will be set below
   };

   offset = _type_offset(sizeof(int), sizeof(Eina_Value_Array));
   main_members[0].name = "size";
   main_members[0].type = EINA_VALUE_TYPE_INT, 0;
   main_members[0].offset = 0;
   main_members[1].name = "array";
   main_members[1].type = EINA_VALUE_TYPE_ARRAY;
   main_members[1].offset = offset;
   desc_struct.size = offset + sizeof(Eina_Value_Array);

   value_struct = eina_value_struct_new(&desc_struct);
   eina_value_struct_set(value_struct, "size", size);

   value_array = eina_value_array_new(EINA_VALUE_TYPE_STRUCT, size);
   for (i = 0; i < size; i++)
     {
        Eina_Value *value_sub_struct = eina_value_struct_new(&desc_sub_struct);
        Eina_Value_Struct st;
        eina_value_struct_set(value_sub_struct, "txt", array[i]);
        eina_value_struct_set(value_sub_struct, "num", i);
        eina_value_get(value_sub_struct, &st);
        eina_value_array_append(value_array, st);
        eina_value_free(value_sub_struct);
     }
   eina_value_struct_value_set(value_struct, "array", value_array);

   eldbus_message_from_eina_value("ia(si)", msg, value_struct);

   eina_value_free(value_struct);
   eina_value_free(value_array);
}
コード例 #4
0
static void
_update_animation(Evas_Object *prefs, Evas_Object *layout)
{
   Eina_Value value;
   Eina_Bool animation;

   elm_prefs_item_value_get(prefs, "main:config:options:animation", &value);
   eina_value_get(&value, &animation);
   if (animation)
     elm_layout_signal_emit(layout, "start", "animation");
   else
     elm_layout_signal_emit(layout, "stop", "animation");
}
コード例 #5
0
static void
_update_animation_time(Evas_Object *prefs, Evas_Object *layout)
{
   Eina_Value value;
   float animation_time;
   Edje_Message_Float msg;

   elm_prefs_item_value_get(prefs, "main:config:options:animation_time", &value);
   eina_value_get(&value, &animation_time);
   msg.val = animation_time;
   edje_object_message_send(elm_layout_edje_get(layout), EDJE_MESSAGE_FLOAT,
                            MSG_ID_VEL, &msg);
}
コード例 #6
0
static void
prop_changed(void *data, Eldbus_Proxy *proxy, void *event_info)
{
   Eldbus_Proxy_Event_Property_Changed *event = event_info;
   E_Music_Control_Module_Context *ctxt = data;

   if (!strcmp(event->name, "PlaybackStatus"))
     {
        const Eina_Value *value = event->value;
        const char *status;

        eina_value_get(value, &status);
        if (!strcmp(status, "Playing"))
          ctxt->playing = EINA_TRUE;
        else
          ctxt->playing = EINA_FALSE;
        music_control_state_update_all(ctxt);
     }
   else if (!strcmp(event->name, "Metadata"))
     {
        parse_metadata(ctxt, (Eina_Value*)event->value);
        music_control_metadata_update_all(ctxt);
     }
}