*NIXコンソール用Google ToDo(Tasks) クライアント
Revision | d92a9b5e33476e743dfb1a63b37c20f43131ff38 (tree) |
---|---|
Zeit | 2020-02-17 22:04:20 |
Autor | ![]() |
Commiter | Koine Yuusuke(koinec) |
@@ -36,6 +36,24 @@ TODOCMDTODOCMDTODOCMDTODOCMDTODOCMDTODOCMDTODOCMDTODOCMDTODOCMDTODOCMDTODO*/ | ||
36 | 36 | #define GLAPI_JSON_KEY_ACCESS_TOKEN "access_token" |
37 | 37 | #define GLAPI_JSON_KEY_REFRESH_TOKEN "refresh_token" |
38 | 38 | #define GLAPI_JSON_KEY_TOKEN_TYPE "token_type" |
39 | + | |
40 | +#define JSON_KEY_LISTS_KIND "\"tasks#taskLists\"" | |
41 | +#define JSON_KEY_LISTS_ITEMS "items" | |
42 | + | |
43 | +#define JSON_KEY_LIST_KIND "\"tasks#taskList\"" | |
44 | +#define JSON_KEY_LIST_ID "id" | |
45 | +#define JSON_KEY_LIST_TITLE "title" | |
46 | +#define JSON_KEY_LIST_UPDATED "updated" | |
47 | + | |
48 | +#define JSON_KEY_TASKS_KIND "\"tasks#tasks\"" | |
49 | +#define JSON_KEY_TASKS_NEXTPAGETOKEN "nextPageToken" | |
50 | +#define JSON_KEY_TASKS_ITEMS "items" | |
51 | + | |
52 | +#define JSON_KEY_TASK_PARENT "parent" | |
53 | +#define JSON_KEY_TASK_POSITION "position" | |
54 | +#define JSON_KEY_TASK_ID "id" | |
55 | +#define JSON_KEY_TASK_TITLE "title" | |
56 | +#define JSON_KEY_TASK_UPDATED "updated" | |
39 | 57 | |
40 | 58 | #endif |
41 | 59 |
@@ -65,12 +65,12 @@ int | ||
65 | 65 | // Parse & Inset ListData --- |
66 | 66 | p_json = json_tokener_parse( (const char *)t_glresult.pb_result ); |
67 | 67 | |
68 | - if( 0x00 != ProcJson_CheckKind( p_json, "\"tasks#taskLists\"" ) ) { | |
68 | + if( 0x00 != ProcJson_CheckKind( p_json, JSON_KEY_LISTS_KIND ) ) { | |
69 | 69 | i_result = -0x02; |
70 | 70 | goto goto_GLAPI_List_GetTaskList_putjson; |
71 | 71 | } |
72 | 72 | |
73 | - p_jitems = ProcJson_GetJsonChildArray( p_json, "items" ); | |
73 | + p_jitems = ProcJson_GetJsonChildArray( p_json, JSON_KEY_LISTS_ITEMS ); | |
74 | 74 | if( NULL == p_jitems ) { |
75 | 75 | i_result = -0x03; |
76 | 76 | goto goto_GLAPI_List_GetTaskList_putjson; |
@@ -90,20 +90,20 @@ int | ||
90 | 90 | assert( NULL != p_tdata ); |
91 | 91 | |
92 | 92 | // kind |
93 | - if( 0x00 != ProcJson_CheckKind( p_jlist, "\"tasks#taskList\"" ) ) { | |
93 | + if( 0x00 != ProcJson_CheckKind( p_jlist, JSON_KEY_LIST_KIND ) ) { | |
94 | 94 | i_result = -0x05; |
95 | 95 | goto goto_GLAPI_List_GetTaskList_putjson; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // id |
99 | - ProcJson_GetJsonChildString( p_tdata->str_id, p_jlist, "id", 64 ); | |
99 | + ProcJson_GetJsonChildString( p_tdata->str_id, p_jlist, JSON_KEY_LIST_ID, 64 ); | |
100 | 100 | strncpy( p_tdata->t_data.str_id, p_tdata->str_id, 64 ); // copy. |
101 | 101 | p_tdata->dw_hash = Common_CalcDJBhash( p_tdata->str_id ); |
102 | 102 | // etag: NOT USE. |
103 | 103 | // title |
104 | - ProcJson_GetJsonChildString( p_tdata->t_data.str_item, p_jlist, "title", 512 ); | |
104 | + ProcJson_GetJsonChildString( p_tdata->t_data.str_item, p_jlist, JSON_KEY_LIST_TITLE, 512 ); | |
105 | 105 | // updated |
106 | - ProcJson_GetJsonChildString( p_tdata->t_data.str_update, p_jlist, "updated", 32 ); | |
106 | + ProcJson_GetJsonChildString( p_tdata->t_data.str_update, p_jlist, JSON_KEY_LIST_UPDATED, 32 ); | |
107 | 107 | // selflink: NOT USE. |
108 | 108 | |
109 | 109 | // level |
@@ -59,31 +59,32 @@ int | ||
59 | 59 | json_object *p_jtask; |
60 | 60 | ToDo_Data *p_tdata; |
61 | 61 | |
62 | - if( 0x00 != ProcJson_CheckKind( p_json, "\"tasks#tasks\"" ) ) { | |
62 | + if( 0x00 != ProcJson_CheckKind( p_json, JSON_KEY_TASKS_KIND ) ) { | |
63 | 63 | i_result = -0x01; |
64 | 64 | goto goto_GLAPI_Tasks_GetTask_RegistTaskfromJson_post; |
65 | 65 | } |
66 | 66 | |
67 | - ProcJson_GetJsonChildString( pstr_nexttoken, p_json, "nextPageToken", 255 ); | |
67 | + ProcJson_GetJsonChildString( pstr_nexttoken, p_json, JSON_KEY_TASKS_NEXTPAGETOKEN, 255 ); | |
68 | 68 | |
69 | - p_jitems = ProcJson_GetJsonChildArray( p_json, "items" ); | |
69 | + p_jitems = ProcJson_GetJsonChildArray( p_json, JSON_KEY_TASKS_ITEMS ); | |
70 | 70 | if( NULL == p_jitems ) { |
71 | 71 | i_result = -0x02; |
72 | 72 | goto goto_GLAPI_Tasks_GetTask_RegistTaskfromJson_post; |
73 | 73 | } |
74 | + | |
74 | 75 | for( i_cnt = 0; i_cnt < json_object_array_length( p_jitems ); i_cnt++ ) { |
75 | 76 | str_parentid[0] = '\0'; |
76 | 77 | p_jtask = json_object_array_get_idx( p_jitems, i_cnt ); |
77 | 78 | assert( NULL != p_jtask ); |
78 | 79 | |
79 | 80 | // parent: |
80 | - ProcJson_GetJsonChildString( str_parentid, p_jtask, "parent", 64 ); | |
81 | + ProcJson_GetJsonChildString( str_parentid, p_jtask, JSON_KEY_TASK_PARENT, 64 ); | |
81 | 82 | if( '\0' != str_parentid[0] ) { b_type = TODODATA_TYPE_SUB; } |
82 | 83 | else { b_type = TODODATA_TYPE_TASK; } |
83 | 84 | i_tparent = p_tlist->i_id; |
84 | 85 | |
85 | 86 | // position: |
86 | - ProcJson_GetJsonChildString( str_position, p_jtask, "position", 32 ); | |
87 | + ProcJson_GetJsonChildString( str_position, p_jtask, JSON_KEY_TASK_POSITION, 32 ); | |
87 | 88 | qw_position = Common_ConvStr2QWord( str_position ); |
88 | 89 | |
89 | 90 | // Alloc ToDo Data --- |
@@ -104,14 +105,14 @@ int | ||
104 | 105 | } |
105 | 106 | */ |
106 | 107 | // id |
107 | - ProcJson_GetJsonChildString( p_tdata->str_id, p_jtask, "id", 64 ); | |
108 | + ProcJson_GetJsonChildString( p_tdata->str_id, p_jtask, JSON_KEY_TASK_ID, 64 ); | |
108 | 109 | strncpy( p_tdata->t_data.str_id, p_tdata->str_id, 64 ); // Copy. |
109 | 110 | p_tdata->dw_hash = Common_CalcDJBhash( p_tdata->str_id ); |
110 | 111 | // etag: NOT USE. |
111 | 112 | // title |
112 | - ProcJson_GetJsonChildString( p_tdata->t_data.str_item, p_jtask, "title", 512 ); | |
113 | + ProcJson_GetJsonChildString( p_tdata->t_data.str_item, p_jtask, JSON_KEY_TASK_TITLE, 512 ); | |
113 | 114 | // updated |
114 | - ProcJson_GetJsonChildString( p_tdata->t_data.str_update, p_jtask, "updated", 32 ); | |
115 | + ProcJson_GetJsonChildString( p_tdata->t_data.str_update, p_jtask, JSON_KEY_TASK_UPDATED, 32 ); | |
115 | 116 | // parentid |
116 | 117 | strncpy( p_tdata->str_parent, str_parentid, 64 ); |
117 | 118 | // selflink: NOT USE. |