aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command.c32
-rw-r--r--src/tagTracker.c53
-rw-r--r--src/tagTracker.h4
3 files changed, 77 insertions, 12 deletions
diff --git a/src/command.c b/src/command.c
index 35045b472..5b3616a40 100644
--- a/src/command.c
+++ b/src/command.c
@@ -613,11 +613,35 @@ int handleClearError(FILE * fp, unsigned int * permission, int argArrayLength,
int handleList(FILE * fp, unsigned int * permission, int argArrayLength,
char ** argArray)
{
- char * arg1 = NULL;
+ int numConditionals = 0;
+ LocateTagItem * conditionals = NULL;
+ int tagType = getLocateTagItemType(argArray[1]);
+ int ret;
- if(argArrayLength==3) arg1 = argArray[2];
- //return printAllKeysOfTable(fp,argArray[1],arg1);
- return 0;
+ if(tagType < 0) {
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not known", argArray[1]);
+ return -1;
+ }
+
+ /* for compatibility with < 0.12.0 */
+ if(argArrayLength==3) {
+ if(tagType != TAG_ITEM_ALBUM) {
+ commandError(fp, ACK_ERROR_ARG,
+ "should be \"%s\" for 3 arguments",
+ mpdTagItemKeys[TAG_ITEM_ALBUM]);
+ return -1;
+ }
+ conditionals = newLocateTagItem(mpdTagItemKeys[TAG_ITEM_ARTIST],
+ argArray[2]);
+ numConditionals = 1;
+ }
+
+ ret = listAllUniqueTags(fp, tagType, numConditionals,conditionals);
+
+ if(conditionals) free(conditionals);
+
+ return ret;
}
int handleMove(FILE * fp, unsigned int * permission, int argArrayLength,
diff --git a/src/tagTracker.c b/src/tagTracker.c
index cea02f471..30ae7641b 100644
--- a/src/tagTracker.c
+++ b/src/tagTracker.c
@@ -16,6 +16,11 @@ static List * tagLists[TAG_NUM_OF_ITEM_TYPES] =
NULL
};
+typedef struct tagTrackerItem {
+ int count;
+ mpd_sint8 visited;
+} TagTrackerItem;
+
char * getTagItemString(int type, char * string) {
ListNode * node;
@@ -26,12 +31,13 @@ char * getTagItemString(int type, char * string) {
}
if((node = findNodeInList(tagLists[type], string))) {
- (*((int *)node->data))++;
+ ((TagTrackerItem *)node->data)->count++;
}
else {
- int * intPtr = malloc(sizeof(int));
- *intPtr = 1;
- node = insertInList(tagLists[type], string, intPtr);
+ TagTrackerItem * item = malloc(sizeof(TagTrackerItem));
+ item->count = 1;
+ item->visited = 0;
+ node = insertInList(tagLists[type], string, item);
}
return node->key;
@@ -53,9 +59,9 @@ void removeTagItemString(int type, char * string) {
node = findNodeInList(tagLists[type], string);
assert(node);
if(node) {
- int * countPtr = node->data;
- (*countPtr)--;
- if(*countPtr <= 0) deleteNodeFromList(tagLists[type], node);
+ TagTrackerItem * item = node->data;
+ item->count--;
+ if(item->count <= 0) deleteNodeFromList(tagLists[type], node);
}
if(tagLists[type]->numberOfNodes == 0) {
@@ -84,7 +90,7 @@ void printMemorySavedByTagTracker() {
while(node != NULL) {
sum -= sizeof(ListNode);
- sum -= sizeof(int);
+ sum -= sizeof(TagTrackerItem);
sum -= sizeof(node->key);
sum += (strlen(node->key)+1)*(*((int *)node->data));
node = node->nextNode;
@@ -103,3 +109,34 @@ void sortTagTrackerInfo() {
sortList(tagLists[i]);
}
}
+
+void resetVisitedFlagsInTagTracker(int type) {
+ ListNode * node;
+
+ if(!tagLists[type]) return;
+
+ node = tagLists[type]->firstNode;
+
+ while(node) {
+ ((TagTrackerItem *)node->data)->visited = 0;
+ node = node->nextNode;
+ }
+}
+
+int wasVisitedInTagTracker(int type, char * str) {
+ int ret;
+ ListNode * node;
+ TagTrackerItem * item;
+
+ if(!tagLists[type]) return 0;
+
+ node = findNodeInList(tagLists[type], str);
+
+ if(!node) return 0;
+
+ item = node->data;
+ ret = item->visited;
+ item->visited = 1;
+
+ return ret;
+}
diff --git a/src/tagTracker.h b/src/tagTracker.h
index fcafde736..7c9740c64 100644
--- a/src/tagTracker.h
+++ b/src/tagTracker.h
@@ -13,4 +13,8 @@ void printMemorySavedByTagTracker();
void sortTagTrackerInfo();
+void resetVisitedFlagsInTagTracker(int type);
+
+int wasVisitedInTagTracker(int type, char * str);
+
#endif