void MprisPlayer::onTrackChanged(QDBusPendingCallWatcher *watcher) { watcher->deleteLater(); TrackInfo info; if (m_version == 1) { QDBusPendingReply<QVariantMap> reply = *watcher; info = convertInfo(reply.argumentAt<0>()); } else if (m_version == 2) { QDBusPendingReply<QDBusVariant> reply = *watcher; QDBusArgument arg = reply.argumentAt<0>().variant().value<QDBusArgument>(); info = convertInfo(qdbus_cast<QVariantMap>(arg)); } TrackInfoEvent event(info); qApp->sendEvent(this, &event); }
void MprisPlayer::onTrackChanged(const QVariantMap &map) { TrackInfo info = convertInfo(map); if (!info.location.isEmpty() && info.time > 0) { TrackInfoEvent event(info); qApp->sendEvent(this, &event); } }
int jouer(Character character[2]){ Client client; int *info = malloc(BUFF_SIZE_RECV * sizeof(int)); int map[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {0}; int continuer,i,j, verif; char choix = '\0'; int goodchoice; connexionToServer(&client); system("clear"); printf("\t\tWaiting for another client\t\t\n"); continuer = 1; goodchoice = 1; while(continuer){ verif = 1; if(goodchoice == 1){ printf("Waiting for new map.\n"); if((info = receiveFromServer(client)) == -1) { printf("Connexion Lost\n"); deconnexionFromServer(&client); continuer = 0; return 0; } if(info[0] == 30 && info[1] == 35) { if(info[3] == 0) { deconnexionFromServer(&client); continuer = 0; return 1; } else if(info[3] == 1) { deconnexionFromServer(&client); continuer = 0; return 0; } } else { for(i = 0; i < 300; i++) { if(!(info[i] < 9 || info[i] == 18)) { printf("Invalid data received Map\n"); verif = 0; } } if(info[300] > 10 || info[301] > 10 || info[302] > 10 || info[305] > 10 || info[306] > 10 || info[307] > 10 || info[303] > 19 || info[308] > 19 || info[304] > 14 || info[309] > 14 || info[303] < 0 || info[308] < 0 || info[304] < 0 || info[309] < 0) { printf("Invalid data received players\n"); verif = 0; } if(verif == 0) { printf("Game finished because of trickery\n"); deconnexionFromServer(&client); continuer = 0; return 0; } else { printf("Map info received, updating\n"); convertInfo(info, character, map); display(map, character); printf("Map info updated\n"); } } } goodchoice = 1; printf("Rentrez une touche (Z Q S D, A pour les bombes, P pour quitter)\n"); scanf("%c", &choix); switch(choix){ case 'z': case 'Z': sendToServer(client, HAUT); printf("Action sent to server.\n"); break; case 'S': case 's': sendToServer(client, BAS); printf("Action sent to server.\n"); break; case 'Q': case 'q': sendToServer(client, GAUCHE); printf("Action sent to server.\n"); break; case 'D': case 'd': sendToServer(client, DROITE); printf("Action sent to server.\n"); break; case 'A': case 'a': sendToServer(client, BOMBE); printf("Action sent to server.\n"); break; case 'P': case 'p': sendToServer(client, EXIT); continuer = 0; deconnexionFromServer(&client); return 0; break; default: printf("ERROR : BAD INPUT\n"); goodchoice = 0; break; } } deconnexionFromServer(&client); return 0; }