5240 } |
5240 } |
5241 return cmd_tagop(args, CMD_TAG_LIST); |
5241 return cmd_tagop(args, CMD_TAG_LIST); |
5242 } |
5242 } |
5243 |
5243 |
5244 int cmd_tagop(CmdArgs *args, int cmd) { |
5244 int cmd_tagop(CmdArgs *args, int cmd) { |
5245 // TODO: port to ucx 3 |
|
5246 return 1; |
|
5247 #if 0 |
|
5248 |
|
5249 SyncFile file; |
5245 SyncFile file; |
5250 int ret = 0; |
5246 int ret = 0; |
5251 char *path = args->argv[0]; |
5247 char *path = args->argv[0]; |
5252 |
5248 |
5253 int err = sync_get_file(args, path, &file, TRUE); |
5249 int err = sync_get_file(args, path, &file, TRUE); |
5280 if(cmd != CMD_TAG_SET) { |
5276 if(cmd != CMD_TAG_SET) { |
5281 char *tag = args->argv[1]; |
5277 char *tag = args->argv[1]; |
5282 char *tagcolor = NULL; // TODO: get color |
5278 char *tagcolor = NULL; // TODO: get color |
5283 |
5279 |
5284 tags = sync_get_file_tags(file.dir, localres, NULL, NULL); |
5280 tags = sync_get_file_tags(file.dir, localres, NULL, NULL); |
5285 CxList *x = NULL; |
5281 CxIterator i = cxListIterator(tags ? tags : cxEmptyList); |
5286 UCX_FOREACH(elm, tags) { |
5282 int x = -1; |
5287 DavTag *t = elm->data; |
5283 cx_foreach(DavTag *, t, i) { |
5288 if(cmd == CMD_TAG_LIST) { |
5284 if(cmd == CMD_TAG_LIST) { |
5289 printf("%s\n", t->name); |
5285 printf("%s\n", t->name); |
5290 } else if(!strcmp(t->name, tag)) { |
5286 } else if(!strcmp(t->name, tag)) { |
5291 x = elm; |
5287 x = i.index; |
5292 break; |
5288 break; |
5293 } |
5289 } |
5294 } |
5290 } |
5295 |
5291 |
5296 if(cmd == CMD_TAG_ADD) { |
5292 if(cmd == CMD_TAG_ADD) { |
5297 if(!x) { |
5293 if(x < 0) { |
5298 DavTag *newtag = malloc(sizeof(DavTag)); |
5294 DavTag *newtag = malloc(sizeof(DavTag)); |
5299 newtag->name = tag; |
5295 newtag->name = tag; |
5300 newtag->color = tagcolor; |
5296 newtag->color = tagcolor; |
5301 tags = ucx_list_append(tags, newtag); |
5297 if(!tags) { |
|
5298 tags = cxLinkedListCreateSimple(CX_STORE_POINTERS); |
|
5299 } |
|
5300 cxListAdd(tags, newtag); |
5302 store_tags = TRUE; |
5301 store_tags = TRUE; |
5303 } |
5302 } |
5304 } else if(cmd == CMD_TAG_REMOVE) { |
5303 } else if(cmd == CMD_TAG_REMOVE) { |
5305 if(tags) { |
5304 if(x >= 0) { |
5306 tags = ucx_list_remove(tags, x); |
5305 cxListRemove(tags, x); |
5307 } |
5306 } |
5308 store_tags = TRUE; |
5307 store_tags = TRUE; |
5309 } |
5308 } |
5310 } else { |
5309 } else { |
5311 if(args->argc == 2) { |
5310 if(args->argc == 2) { |