/** * This function sets the favourite bit on titles found in the given list */ int applyFAVlist( mptitle *root, struct marklist_t *favourites ) { struct marklist_t *ptr = NULL; mptitle *runner=root; int cnt=0; do { activity( "Favourites " ); ptr=favourites; while( ptr ) { if( matchTitle( runner, ptr->dir ) ) { addMessage( 3, "[F] %s: %s", ptr->dir, runner->display ); if( !( runner->flags & MP_FAV ) ) { runner->flags|=MP_FAV; cnt++; } ptr=NULL; } else { ptr=ptr->next; } } runner=runner->next; } while ( runner != root ); addMessage( 1, "Marked %i favourites", cnt ); return cnt; }
/** * Marks an entry as DNP and removes it and additional matching titles * from the playlist. Matching is done based on range * * returns the next item in the list. If the next item is NULL, the previous * item will be returned. If entry was the last item in the list NULL will be * returned. */ mpplaylist *removeByPattern( mpplaylist *plentry, const char *pat ) { char pattern[NAMELEN+2]; mptitle *entry=plentry->title; mptitle *runner=entry; strncpy( pattern, pat, 2 ); switch( pattern[0] ){ case 'l': strltcpy( &pattern[2], entry->album, NAMELEN ); break; case 'a': strltcpy( &pattern[2], entry->artist, NAMELEN ); break; case 'g': strltcpy( &pattern[2], entry->genre, NAMELEN ); break; case 't': strltcpy( &pattern[2], entry->title, NAMELEN ); break; case 'p': strltcpy( &pattern[2], entry->path, NAMELEN ); break; case 'd': strltcpy( &pattern[2], entry->display, NAMELEN ); break; default: addMessage( 0, "Unknown pattern %s!", pat ); addMessage( 0, "Using display instead" ); strltcpy( &pattern[2], entry->display, NAMELEN ); break; } addMessage( 1, "Rule: %s", pattern ); do { if( !(runner->flags & MP_DNP ) && matchTitle( runner, pattern ) ) { runner->flags |= MP_DNP; } runner=runner->next; } while( runner != entry ); return remFromPL(plentry); }
bool Rules::match(const Client* c) const { if (!matchType(c->windowType(true))) return false; if (!matchWMClass(c->resourceClass(), c->resourceName())) return false; if (!matchRole(c->windowRole())) return false; if (!matchTitle(c->caption(false))) return false; if (!matchClientMachine(c->clientMachine()->hostName(), c->clientMachine()->isLocal())) return false; return true; }
/** * applies the dnplist on a list of titles and marks matching titles * if the title is part of the playlist it will be removed from the playlist * too. This may lead to double played artists though... * * returns the number of marked titles or -1 on error */ int applyDNPlist( mptitle *base, struct marklist_t *list ) { mptitle *pos = base; struct marklist_t *ptr = list; mpplaylist *pl=getConfig()->current; int cnt=0; if( NULL == base ) { addMessage( 0, "%s: No music loaded", __func__ ); return -1; } if( NULL == list ) { return 0; } do { ptr=list; while( ptr ) { if( matchTitle( pos, ptr->dir ) ) { addMessage( 3, "[D] %s: %s", ptr->dir, pos->display ); pos->flags |= MP_DNP; break; } ptr=ptr->next; } pos=pos->next; } while( pos != base ); while( pl != NULL ) { if( pl->title->flags & MP_DNP ) { if( pl == getConfig()->current ) { getConfig()->current=pl->next; } pl=remFromPL(pl); } else { pl=pl->next; } } addMessage( 1, "Marked %i titles as DNP", cnt ); return cnt; }
bool Rules::match(const Client* c) const { if (!matchType(c->windowType(true))) return false; if (!matchWMClass(c->resourceClass(), c->resourceName())) return false; if (!matchRole(c->windowRole().toLower())) return false; if (!matchClientMachine(c->clientMachine()->hostName(), c->clientMachine()->isLocal())) return false; if (titlematch != UnimportantMatch) // track title changes to rematch rules QObject::connect(c, &Client::captionChanged, c, &Client::evaluateWindowRules, // QueuedConnection, because title may change before // the client is ready (could segfault!) static_cast<Qt::ConnectionType>(Qt::QueuedConnection|Qt::UniqueConnection)); if (!matchTitle(c->caption(false))) return false; return true; }