From cs.schoffit at free.fr Tue Oct 2 11:55:17 2007 From: cs.schoffit at free.fr (Sylvie et Christian Schoffit) Date: Tue, 2 Oct 2007 11:55:17 +0200 Subject: [Pouchintv-dev] =?iso-8859-1?q?Petit_bug_enregistrement_programm?= =?iso-8859-1?q?=E9?= References: Message-ID: <006201c804da$56e85ef0$4101a8c0@bunny> Bonjour J'ai découvert un petit bug : l'arrêt automatique de Pouchin TV en fin d'enregistrement ne fonctionne plus dans la r85. Pour corriger le bug, il suffit de commenter ou de supprimer l'instruction : enregistrements_actuels[grab].apres = apr_rien; dans la fonction "void stop_record(int grab)" Bon courage, Christian From gingko_pouchintv at nospam.homelinux.org Tue Oct 2 12:58:47 2007 From: gingko_pouchintv at nospam.homelinux.org (Gingko) Date: Tue, 2 Oct 2007 12:58:47 +0200 Subject: [Pouchintv-dev] =?iso-8859-1?q?Petit_bug_enregistrement_programm?= =?iso-8859-1?q?=E9?= References: <006201c804da$56e85ef0$4101a8c0@bunny> Message-ID: <003e01c804e3$363ddb90$29a0a8c0@GReeves> ----- Message d'origine ----- De : "Sylvie et Christian Schoffit" À : Envoyé : mardi 2 octobre 2007 11:55 Objet : [Pouchintv-dev] Petit bug enregistrement programmé > Bonjour > > J'ai découvert un petit bug : l'arrêt automatique de Pouchin TV en fin > d'enregistrement ne fonctionne plus dans la r85. > > Pour corriger le bug, il suffit de commenter ou de supprimer > l'instruction > : > > enregistrements_actuels[grab].apres = apr_rien; > > dans la fonction "void stop_record(int grab)" > > Bon courage, > > Christian Bonjour et merci, Je prends ça en note, pour quand j'aurai le temps de m'en occuper. Sauf que je ne ferai peut-être pas exactement comme ça. :-) Gingko From pouchintv-svn at baysse.fr Wed Oct 3 22:59:12 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Wed, 3 Oct 2007 22:59:12 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r86 - trunk Message-ID: <20071003205913.04F9B5F2A5@mail.baysse.fr> Author: lolo_32 Date: 2007-10-03 22:59:12 +0200 (Wed, 03 Oct 2007) New Revision: 86 Modified: trunk/LCD.cpp trunk/base.h trunk/epg.cpp trunk/grabber.cpp trunk/graph.cpp trunk/ini.cpp trunk/main.cpp Log: * remplacement des fonctions wsprintf par swprintf_s, et remplacement des nombres par _countof( ) pour toutes les variables ou l'utilisation etait faisable; * remplacement de quelques chaines de caracteres de char* en wchar_t*; * ajout d'une entree dans le menu contextuel dans l'icone su systray permettant de reduire Pouchin TV Mod sans cliquer sur le bouton Reduire de la fenetre; * place la fenetre de Pouchin TV Mod au devant (restaure la fenetre le cas echeant) si on lance un second Pouchin TV Mod avant de s'arreter. Correction des bugs de la precedente version: * suppression de l'option "multiplex" dans la fenetre EPG si on compile sans le support de l'enregistrement du multiplex; * reactivation de l'arret de Pouchin TV Mod ou du PC lors de de l'enregistrement; * relit la liste des chaines apres validation d'une recherche, ce qui permet de recharger les icones; * replace la fenetre normalement lorsque l'on supprime l'option "Rester toujours devant", ce qui ne marchait plus. Modified: trunk/LCD.cpp =================================================================== --- trunk/LCD.cpp 2007-09-29 12:57:46 UTC (rev 85) +++ trunk/LCD.cpp 2007-10-03 20:59:12 UTC (rev 86) @@ -231,9 +231,9 @@ SetTextAlign(this->m_hdc, TA_RIGHT); char volume[46]; if (this->m_mute) - sprintf(volume, "Sourdine %i", this->m_volume); + sprintf_s(volume, _countof(volume), "Sourdine %i", this->m_volume); else - sprintf(volume, "Volume %i", this->m_volume); + sprintf_s(volume, _countof(volume), "Volume %i", this->m_volume); TextOutA(this->m_hdc, this->m_lcdDeviceDesc.Width-1, 1, volume, (int)strlen(volume)); // Alignement à gauche Modified: trunk/base.h =================================================================== --- trunk/base.h 2007-09-29 12:57:46 UTC (rev 85) +++ trunk/base.h 2007-10-03 20:59:12 UTC (rev 86) @@ -231,7 +231,7 @@ struct Langue { char code[8]; - char lang[32]; + wchar_t lang[32]; }; struct Frequence { Modified: trunk/epg.cpp =================================================================== --- trunk/epg.cpp 2007-09-29 12:57:46 UTC (rev 85) +++ trunk/epg.cpp 2007-10-03 20:59:12 UTC (rev 86) @@ -146,7 +146,9 @@ SendDlgItemMessage(hwndDlg, IDC_METHOD_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("TS")); SendDlgItemMessage(hwndDlg, IDC_METHOD_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("PS")); +#if USE_RECORD_STREAM SendDlgItemMessage(hwndDlg, IDC_METHOD_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Multiplex")); +#endif SendDlgItemMessage(hwndDlg, IDC_METHOD_EPG, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hwndDlg, IDC_AUDIO_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Audio 1")); SendDlgItemMessage(hwndDlg, IDC_AUDIO_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Audio 2")); Modified: trunk/grabber.cpp =================================================================== --- trunk/grabber.cpp 2007-09-29 12:57:46 UTC (rev 85) +++ trunk/grabber.cpp 2007-10-03 20:59:12 UTC (rev 86) @@ -225,7 +225,7 @@ // si la video est valide, on verifie que pas de discontinuité - if (vid_valid) { + if (vid_valid) { int current = p[3]&15; if ( ( (current - vid_continuity_counter) & 15 ) != 1 ) { Modified: trunk/graph.cpp =================================================================== --- trunk/graph.cpp 2007-09-29 12:57:46 UTC (rev 85) +++ trunk/graph.cpp 2007-10-03 20:59:12 UTC (rev 86) @@ -1100,7 +1100,7 @@ IBaseFilter * pGrabber; for (int i=0; igetInt(var); canal.son[i].type = (BYTE)pNode->getInt(var2); pNode->getStr(var3, canal.son[i].lang); @@ -395,8 +395,8 @@ for (int i=0;igetInt(var); pNode->getStr(var2, canal.autre[i].lang); } @@ -409,8 +409,8 @@ // Concaténation des chemins + chaine NomProtege nom(canal.nom, '_'); - wsprintf(image_prog, L"%s\\Icones\\%S.bmp", pouchindir_prog, nom.nom); - wsprintf(image_conf, L"%s\\Icones\\%S.bmp", pouchindir_conf, nom.nom); + swprintf_s(image_prog, _countof(image_prog), L"%s\\Icones\\%S.bmp", pouchindir_prog, nom.nom); + swprintf_s(image_conf, _countof(image_conf), L"%s\\Icones\\%S.bmp", pouchindir_conf, nom.nom); WIN32_FIND_DATA file_data; HANDLE handle = FindFirstFile(image_conf, &file_data); @@ -809,17 +809,17 @@ prog.pszText = const_cast(programme.nom); SendDlgItemMessage(hdlg, item, LVM_INSERTITEMA, 0, (LPARAM)&prog); prog.iSubItem = 1; - sprintf(buffer, "%u", programme.chaine); + sprintf_s(buffer, _countof(buffer), "%u", programme.chaine); prog.pszText = buffer; SendDlgItemMessage(hdlg, item, LVM_SETITEMA, 0, (LPARAM)&prog); prog.iSubItem = 2; - sprintf(buffer, "%02i:%02i:%02i %02i/%02i/%04i", + sprintf_s(buffer, _countof(buffer), "%02i:%02i:%02i %02i/%02i/%04i", programme.debut.wHour, programme.debut.wMinute, programme.debut.wSecond, programme.debut.wDay, programme.debut.wMonth, programme.debut.wYear); prog.pszText = buffer; SendDlgItemMessage(hdlg, item, LVM_SETITEMA, 0, (LPARAM)&prog); prog.iSubItem = 3; - sprintf(buffer, "%02i:%02i:%02i %02i/%02i/%04i", + sprintf_s(buffer, _countof(buffer), "%02i:%02i:%02i %02i/%02i/%04i", programme.fin.wHour, programme.fin.wMinute, programme.fin.wSecond, programme.fin.wDay, programme.fin.wMonth, programme.fin.wYear); prog.pszText = buffer; Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-09-29 12:57:46 UTC (rev 85) +++ trunk/main.cpp 2007-10-03 20:59:12 UTC (rev 86) @@ -92,7 +92,7 @@ int sonCourant = 0; int nouvelleChaine = 0; long volumeCourant = 0; -char statusvol[40]; +wchar_t statusvol[40]; static bool muted = false; std::vector freq_scan; @@ -180,7 +180,7 @@ FILE * f; f = fopen("pouchin.log", "a"); if (f) { - fwprintf(f, s); + fwprintf_s(f, s); fclose(f); } #endif // #if USE_CONSOLE==-1 @@ -559,36 +559,36 @@ Langue Lang; - strncpy(Lang.code, "fra", 8); - strncpy(Lang.lang, "Français", 32); + strncpy(Lang.code, "fra", _countof(Lang.code)); + wcscpy_s(Lang.lang, _countof(Lang.lang), L"Français"); Tab_Lang.push_back(Lang); - strncpy(Lang.code, "fre", 8); - strncpy(Lang.lang, "Français", 32); + strncpy(Lang.code, "fre", _countof(Lang.code)); + wcscpy_s(Lang.lang, _countof(Lang.lang), L"Français"); Tab_Lang.push_back(Lang); - strncpy(Lang.code, "eng", 8); - strncpy(Lang.lang, "Anglais", 32); + strncpy(Lang.code, "eng", _countof(Lang.code)); + wcscpy_s(Lang.lang, _countof(Lang.lang), L"Anglais"); Tab_Lang.push_back(Lang); - strncpy(Lang.code, "ang", 8); - strncpy(Lang.lang, "Anglais", 32); + strncpy(Lang.code, "ang", _countof(Lang.code)); + wcscpy_s(Lang.lang, _countof(Lang.lang), L"Anglais"); Tab_Lang.push_back(Lang); - strncpy(Lang.code, "deu", 8); - strncpy(Lang.lang, "Allemand", 32); + strncpy(Lang.code, "deu", _countof(Lang.code)); + wcscpy_s(Lang.lang, _countof(Lang.lang), L"Allemand"); Tab_Lang.push_back(Lang); - strncpy(Lang.code, "spa", 8); - strncpy(Lang.lang, "Espagnol", 32); + strncpy(Lang.code, "spa", _countof(Lang.code)); + wcscpy_s(Lang.lang, _countof(Lang.lang), L"Espagnol"); Tab_Lang.push_back(Lang); - strncpy(Lang.code, "ita", 8); - strncpy(Lang.lang, "Italien", 32); + strncpy(Lang.code, "ita", _countof(Lang.code)); + wcscpy_s(Lang.lang, _countof(Lang.lang), L"Italien"); Tab_Lang.push_back(Lang); - strncpy(Lang.code, "por", 8); - strncpy(Lang.lang, "Portugais", 32); + strncpy(Lang.code, "por", _countof(Lang.code)); + wcscpy_s(Lang.lang, _countof(Lang.lang), L"Portugais"); Tab_Lang.push_back(Lang); } @@ -602,22 +602,22 @@ HMENU pistes = CreatePopupMenu(); while (iSetCallback(NULL, 0); enregistrements_actuels[grab].chaine = -1; - enregistrements_actuels[grab].apres = apr_rien; update_menu_recording(hWnd); update_chaines_menu(hWnd); } @@ -845,7 +850,7 @@ wchar_t tab[256]; - GetMenuString(origMenu, i, tab, 256, MF_BYPOSITION); + GetMenuString(origMenu, i, tab, _countof(tab), MF_BYPOSITION); UINT id = GetMenuItemID(origMenu, i); @@ -858,12 +863,19 @@ } -static void popup_menu(void) { +static void popup_menu(bool from_tray_icon = false) { POINT pos; GetCursorPos(&pos); HMENU pop = CreatePopupMenu(); + if (from_tray_icon && !IsMinimized(hWnd)) { + // Ajoute d'autres infos si venant du tray + + AppendMenu(pop, MF_STRING, SC_MINIMIZE, L"Ré&duire la fenêtre"); + AppendMenu(pop, MF_SEPARATOR, NULL, NULL); + } + HMENU copie0 = copie_menu(GetSubMenu(mainMenu, 0)); HMENU copie1 = copie_menu(GetSubMenu(mainMenu, 1)); HMENU copie2 = copie_menu(GetSubMenu(mainMenu, 2)); @@ -884,8 +896,7 @@ ShowCursor(TRUE); - TrackPopupMenuEx(pop, TPM_LEFTALIGN | TPM_LEFTBUTTON, - pos.x, pos.y, hWnd, NULL); + TrackPopupMenuEx(pop, TPM_LEFTALIGN | TPM_LEFTBUTTON, pos.x, pos.y, hWnd, NULL); ShowCursor(FALSE); @@ -999,10 +1010,10 @@ if (is_vista) { if (!muted) - sprintf(statusvol, "Volume %i", (volumeCourant+8000)/80); + swprintf_s(statusvol, _countof(statusvol), L"Volume %i", (volumeCourant+8000)/80); else - sprintf(statusvol, "Sourdine %i", (volumeCourant+8000)/80); - SendMessageA(hStatus, SB_SETTEXTA, 5, (LPARAM)statusvol); + swprintf_s(statusvol, _countof(statusvol), L"Sourdine %i", (volumeCourant+8000)/80); + SendMessage(hStatus, SB_SETTEXT, 5, (LPARAM)statusvol); } } @@ -1027,7 +1038,7 @@ COPYDATASTRUCT msndata; WCHAR buffer[1024]; - wsprintfW(buffer, L"\\0Music\\01\\0{0} - {1}\\0%S\\0%S\\0\\0\\0", canal_courant.nom, canal_courant.prog1.nom); + swprintf_s(buffer, _countof(buffer), L"\\0Music\\01\\0{0} - {1}\\0%S\\0%S\\0\\0\\0", canal_courant.nom, canal_courant.prog1.nom); msndata.dwData = 0x547; msndata.lpData = &buffer; @@ -1466,10 +1477,10 @@ } } -static LRESULT AddLineToList(HWND hListItem, LPCSTR str) { +static LRESULT AddLineToList(HWND hListItem, LPCWSTR str) { return SendMessage(hListItem, LB_SETTOPINDEX, - (WPARAM)SendMessageA(hListItem, LB_ADDSTRING, 0, (LPARAM)str), + (WPARAM)SendMessage(hListItem, LB_ADDSTRING, 0, (LPARAM)str), 0); } @@ -1535,7 +1546,7 @@ // // Définir les tabulations dans la list box : SendMessage(hListItem, LB_SETTABSTOPS, (WPARAM)_countof(a_tabs), (LPARAM)a_tabs); - AddLineToList(hListItem, "Cliquez sur « Démarrer » pour commencer la recherche"); + AddLineToList(hListItem, L"Cliquez sur « Démarrer » pour commencer la recherche"); //i = (size_t)-1; scanState = ss_idle; return TRUE; @@ -1554,7 +1565,7 @@ EnableWindow(hOkBut, FALSE); // Désactiver le bouton "Accepter" EnableWindow(hComboItem, FALSE); // Désactiver la liste des villes PostMessage(hwndDlg, WM_APP, 0, 0); - SetWindowTextA(hStartBut, "Arrêter"); + SetWindowText(hStartBut, L"Arrêter"); scanState = ss_running; stopping = false; cancelCode = -1; @@ -1563,7 +1574,7 @@ break; case ss_running: EnableWindow(hStartBut, FALSE); - AddLineToList(hListItem, "Arrêt en cours"); + AddLineToList(hListItem, L"Arrêt en cours"); scanState = ss_stopping; stopping = true; } @@ -1573,7 +1584,7 @@ EnableWindow(hStartBut, FALSE); if (tuning) { // On est en récursion à l'intérieur de "tune" - AddLineToList(hListItem, "Annulation en cours"); + AddLineToList(hListItem, L"Annulation en cours"); stopping = true; scanState = ss_cancelling; return FALSE; @@ -1591,8 +1602,9 @@ return TRUE; case MAKELONG(IDOK, BN_CLICKED): RecupereNomVille(hComboItem); - sauve_chaines(); // sauvegarde les chaînes dans le ini - save_config(); // sauvegarde la configuration (le nom de ville peut avoir changé) + sauve_chaines(); // sauvegarde les chaînes dans le ini + save_config(); // sauvegarde la configuration (le nom de ville peut avoir changé) + lit_chaines(); // recharge les chaines (et les icones en plus) EndDialog(hwndDlg, 0); // 0 = pas d'erreur return TRUE; case MAKELONG(IDC_COMBO_VILLE, CBN_SELCHANGE): @@ -1617,13 +1629,13 @@ SendMessage(hProgBar, PBM_SETPOS, 1, 0); } const Frequence & freq = freq_scan[wParam]; - char szFreq[16]; - char szTemp[128]; + wchar_t szFreq[16]; + wchar_t szTemp[128]; unsigned last_num = Canaux.size(); - sprintf_s(szFreq, _countof(szFreq), "%03u,%03u MHz", freq.mhz/1000, freq.mhz%1000); - sprintf_s(szTemp, _countof(szTemp), "Examen canal %u à %s", freq.canal_no, szFreq); - SetWindowTextA(hInfoText, szTemp); + swprintf_s(szFreq, _countof(szFreq), L"%03u,%03u MHz", freq.mhz/1000, freq.mhz%1000); + swprintf_s(szTemp, _countof(szTemp), L"Examen canal %u à %s", freq.canal_no, szFreq); + SetWindowText(hInfoText, szTemp); tuning = true; tune(hwndDlg, freq, &stopping); @@ -1638,7 +1650,7 @@ (canal.mpeg4_pid!=0 ? 'X': '2') : (canal.mpeg4_pid!=0 ? '4': '?'); - sprintf_s(szTemp, _countof(szTemp), "%u\t%s\t%s\t%u\t%s\t%c", canal.canal_no, szFreq, + swprintf_s(szTemp, _countof(szTemp), L"%u\t%s\t%S\t%u\t%S\t%c", canal.canal_no, szFreq, *canal.groupe ? canal.groupe : "", canal.numero_nit, canal.nom, norme); AddLineToList(hListItem, szTemp); } @@ -1648,7 +1660,7 @@ } tuning = stopping = false; - SetWindowTextA(hInfoText, ""); + SetWindowText(hInfoText, L""); switch (scanState) { case ss_cancelling: @@ -1658,8 +1670,8 @@ case ss_stopping: EnableWindow(hStartBut, TRUE); EnableWindow(hComboItem, TRUE); // Réactiver la liste des villes - AddLineToList(hListItem, "Interrompu"); - SetWindowTextA(hStartBut, "Recommencer"); + AddLineToList(hListItem, L"Interrompu"); + SetWindowText(hStartBut, L"Recommencer"); scanState = ss_idle; break; case ss_running: @@ -1669,14 +1681,14 @@ } else { // Recherche terminée : chaineIDs.clear(); // Vide la table des numéros de chaînes, dont on n'aura plus besoin - SetWindowTextA(hStartBut, "Recommencer"); + SetWindowText(hStartBut, L"Recommencer"); scanState = ss_idle; EnableWindow(hComboItem, TRUE); // Réactiver la liste des villes EnableWindow(hOkBut, TRUE); - AddLineToList(hListItem, "Recherche des fréquences terminée"); + AddLineToList(hListItem, L"Recherche des fréquences terminée"); if (Canaux.empty()) { erreur(L"Aucune chaîne n'a été trouvée"); - AddLineToList(hListItem, "Aucune chaîne n'a été trouvée"); + AddLineToList(hListItem, L"Aucune chaîne n'a été trouvée"); } else restaure_chaine(numeroChaine); } @@ -1689,7 +1701,7 @@ // Traitement du message d'information envoyé par la fonction "tune" // au début de l'analyse de la NIT : SendMessage(hProgBar, PBM_SETPOS, index+(nit_chargee ? 4 : 2), 0); - SetWindowTextA(hInfoText, "Lecture des numéros des chaînes"); + SetWindowText(hInfoText, L"Lecture des numéros des chaînes"); } return FALSE; @@ -1784,7 +1796,7 @@ && DiffTime(Programmes[i].fin, prog.debut) >= 0 && getFrequence(Programmes[i].chaine) != Canaux[index].frequence) { wchar_t messageErreur[1024]; - wsprintf(messageErreur, L"Chevauchement des horaires avec \"%S\", qui ne partage pas le même multiplex!", Programmes[i].nom); + swprintf_s(messageErreur, _countof(messageErreur), L"Chevauchement des horaires avec \"%S\", qui ne partage pas le même multiplex!", Programmes[i].nom); erreur(messageErreur); return 1; } @@ -1982,7 +1994,6 @@ case IDC_REMOVE: - if(sel != -1) { SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_DELETEITEM, sel, 0); Programme &prog = Programmes[sel]; @@ -1998,7 +2009,6 @@ return TRUE; case IDC_MODIFY: - if(sel != -1) { Programme prog = Programmes[sel]; Programmes.erase(Programmes.begin() + sel); @@ -2130,8 +2140,7 @@ if (result != 0) return result; - if (Canaux.size() == 0) - { + if (Canaux.size() == 0) { erreur(L"Aucune chaîne n'est dans le fichier"); } @@ -2206,11 +2215,11 @@ if ( versionActuelle != NULL) { // Version actuelle est une version beta versionActuelle++; - sprintf_s(version, 256, "%s%i.%i~svn-r", version, major, minor); + sprintf_s(version, _countof(version), "%s%i.%i~svn-r", version, major, minor); } else { - sprintf_s(version, 256, "%s%i.%i-", version, major, minor); + sprintf_s(version, _countof(version), "%s%i.%i-", version, major, minor); } - strcat_s(version, 256, (LPCSTR)resource.contenu); + strcat_s(version, _countof(version), (LPCSTR)resource.contenu); SetDlgItemTextA(hwndDlg, IDC_VERSION, version); @@ -2301,33 +2310,29 @@ { BOOLEAN boo; - if (SUCCEEDED(pStats->get_SignalLocked(&boo))) - { + if (SUCCEEDED(pStats->get_SignalLocked(&boo))) { HWND hText = GetDlgItem(hwndDlg, IDC_SIGNAL_LOCK); SetWindowText(hText, boo ? L"Oui" : L"Non"); } - if (SUCCEEDED(pStats->get_SignalPresent(&boo))) - { + if (SUCCEEDED(pStats->get_SignalPresent(&boo))) { HWND hText = GetDlgItem(hwndDlg, IDC_SIGNAL_PRESENT); SetWindowText(hText, boo ? L"Oui" : L"Non"); } LONG l; - if (SUCCEEDED(pStats->get_SignalQuality(&l))) - { + if (SUCCEEDED(pStats->get_SignalQuality(&l))) { HWND hText = GetDlgItem(hwndDlg, IDC_SIGNAL_QUALITY); wchar_t buf[256]; - swprintf_s(buf, 256, L"%i", l); + swprintf_s(buf, _countof(buf), L"%i", l); SetWindowText(hText, buf); } - if (SUCCEEDED(pStats->get_SignalStrength(&l))) - { + if (SUCCEEDED(pStats->get_SignalStrength(&l))) { HWND hText = GetDlgItem(hwndDlg, IDC_SIGNAL_STRENGTH); wchar_t buf[256]; - swprintf_s(buf, 256, L"%i", l); + swprintf_s(buf, _countof(buf), L"%i", l); SetWindowText(hText, buf); } } @@ -2590,7 +2595,11 @@ hWndInsertAfter = HWND_TOPMOST; if (!change && GetTopWindow(NULL) != hWnd) change = true; - }; + } else { + wPosFlags &= ~SWP_NOZORDER; + hWndInsertAfter = HWND_NOTOPMOST; + change = true; + } if (newShowCmd != wpl.showCmd) { wpl.showCmd = newShowCmd; @@ -2786,6 +2795,7 @@ // Arrête Windows, et force toutes les applications à s'arrêter. if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_MINOR_UPGRADE |SHTDN_REASON_FLAG_PLANNED)) + // Erreur, on annule tout return false; // Tout est OK, le système s'arrête... @@ -2804,7 +2814,7 @@ internet.RecupereFichier(versionInternet, &taille); LPWSTR wsVersion = new wchar_t[taille + 2]; - wsprintf(wsVersion, L"%S", versionInternet); + swprintf_s(wsVersion, taille + 2, L"%S", versionInternet); CXMLWrapper xml; if (xml.charge_xml(wsVersion) == S_OK) { @@ -2873,7 +2883,7 @@ versionActuelle++; char version[15] = "~svn-r"; - strcat_s(version, 15, versionActuelle); + strcat_s(version, _countof(version), versionActuelle); myprintf(L"\nVersion locale:\t\t%i.%i%S\nVersion beta:\t\t%i.%i%S\n\n", major, @@ -3122,7 +3132,7 @@ // Arrêt de l'ordinateur if (after == apr_eteindrePC) { if (!shutdown()) { - MessageBox(hWnd, L"Impossible d'arrêter l'ordinateur", L"Erreur", MB_ICONERROR | MB_OK); + erreur(L"Impossible d'arrêter l'ordinateur"); } } } @@ -3252,7 +3262,7 @@ SetTextAlign(hdc, TA_RIGHT); char numeros[5]; - _itoa_s(nouvelleChaine, numeros, 5, 10); + _itoa_s(nouvelleChaine, numeros, _countof(numeros), 10); //myprintf(L"Actualise la chaine: %d\t%S\n", nouvelleChaine, numeros); TextOutA(hdc, rect.right-10, rect.top, numeros, (int)strlen(numeros)); @@ -3277,7 +3287,7 @@ SetTextAlign(hdc, TA_LEFT); char str[256]; - int taille = sprintf(str, "Volume %i", (volumeCourant+8000)/80); + int taille = sprintf_s(str, _countof(str), "Volume %i", (volumeCourant+8000)/80); TextOutA(hdc, rect.left+10, rect.bottom-hauteur, str, taille); } @@ -3287,7 +3297,7 @@ SetTextAlign(hdc, TA_LEFT); char str[256]; - int taille = sprintf(str, "Zoom %i%%", zoom_ratio); + int taille = sprintf_s(str, _countof(str), "Zoom %i%%", zoom_ratio); TextOutA(hdc, rect.left+10, rect.bottom-hauteur, str, taille); } @@ -3727,6 +3737,10 @@ SetTimer(hWnd, TIMER_UPDATE, USER_TIMER_MINIMUM, NULL); break; + case SC_MINIMIZE: + SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, NULL); + break; + default: if (wID>=0 && wID<=100) { // cas changement chaîne @@ -3936,7 +3950,7 @@ break; case WM_CONTEXTMENU: case WM_RBUTTONDOWN: - popup_menu(); + popup_menu(true); break; } break; @@ -4148,6 +4162,13 @@ CreateMutex(NULL, TRUE, szAppName); if (GetLastError() == ERROR_ALREADY_EXISTS) { + // Affiche la fenêtre de Pouchin TV Mod déjà lancée au premier plan + HWND pouchintvmod = FindWindow(szAppName, L"Pouchin TV Mod"); + BOOL ret = 0; + if (pouchintvmod) { + ret = SendMessage(pouchintvmod, WM_SYSCOMMAND, SC_RESTORE, NULL); + ret = SetForegroundWindow(pouchintvmod); + } return 0; } @@ -4161,6 +4182,9 @@ SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, pouchindir_conf); wcscat_s(pouchindir_conf, _countof(pouchindir_conf), L"\\Pouchin TV Mod\\"); + // Place le répertoire courant sur le répertoire de Pouchin TV Mod + SetCurrentDirectory(pouchindir_prog); + // Crée le répertoire. S'il existe, ne pose pas de problème CreateDirectory(pouchindir_conf, NULL); @@ -4180,7 +4204,7 @@ if (_wfopen_s(&fop, fileName, L"w")) { myprintf(L"Erreur écriture\n"); } else { - fprintf(fop, (LPCSTR)canaux.contenu); + fprintf_s(fop, (LPCSTR)canaux.contenu); fclose(fop); } delete [] canaux.contenu; From laurent at baysse.fr Wed Oct 3 23:13:02 2007 From: laurent at baysse.fr (Laurent Baysse) Date: Wed, 03 Oct 2007 23:13:02 +0200 Subject: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r86 - trunk In-Reply-To: <20071003205913.04F9B5F2A5@mail.baysse.fr> References: <20071003205913.04F9B5F2A5@mail.baysse.fr> Message-ID: <470405DE.10100@baysse.fr> pouchintv-svn at baysse.fr a écrit : > Author: lolo_32 > Date: 2007-10-03 22:59:12 +0200 (Wed, 03 Oct 2007) > New Revision: 86 > > Modified: > trunk/LCD.cpp > trunk/base.h > trunk/epg.cpp > trunk/grabber.cpp > trunk/graph.cpp > trunk/ini.cpp > trunk/main.cpp > Log: > * remplacement des fonctions wsprintf par swprintf_s, et remplacement des nombres par _countof( ) pour toutes les variables ou l'utilisation etait faisable; > * remplacement de quelques chaines de caracteres de char* en wchar_t*; > * ajout d'une entree dans le menu contextuel dans l'icone su systray permettant de reduire Pouchin TV Mod sans cliquer sur le bouton Reduire de la fenetre; > * place la fenetre de Pouchin TV Mod au devant (restaure la fenetre le cas echeant) si on lance un second Pouchin TV Mod avant de s'arreter. > > Correction des bugs de la precedente version: > * suppression de l'option "multiplex" dans la fenetre EPG si on compile sans le support de l'enregistrement du multiplex; > * reactivation de l'arret de Pouchin TV Mod ou du PC lors de de l'enregistrement; > * relit la liste des chaines apres validation d'une recherche, ce qui permet de recharger les icones; > * replace la fenetre normalement lorsque l'on supprime l'option "Rester toujours devant", ce qui ne marchait plus. > > > Par contre, y'a encore ce problème au démarrage de Pouchin TV Mod, sans fichier «chaines.xml», mais j'ai pas trouvé d'où ça vient exactement... Je suis désolé de faire un commit, connaissant les problèmes :( -- Laurent From gingko_pouchintv at nospam.homelinux.org Thu Oct 4 00:29:24 2007 From: gingko_pouchintv at nospam.homelinux.org (Gingko) Date: Thu, 4 Oct 2007 00:29:24 +0200 Subject: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r86 - trunk References: <20071003205913.04F9B5F2A5@mail.baysse.fr> <470405DE.10100@baysse.fr> Message-ID: <001d01c8060c$da2c2700$0a00a8c0@gilles> ----- Original Message ----- From: "Laurent Baysse" To: "Liste utilisée par les développeurs" Sent: Wednesday, October 03, 2007 11:13 PM Subject: Re: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r86 - trunk > Par contre, y'a encore ce problème au démarrage de Pouchin TV Mod, sans > fichier «chaines.xml», mais j'ai pas trouvé d'où ça vient exactement... > Je suis désolé de faire un commit, connaissant les problèmes :( > > -- > Laurent Je suis en train de chercher ça aussi. Mes observations provisoires sont les suivantes : Je n'arrive à reproduire le crash que si j'utilise DScaler (et il faut que j'installe sur un autre ordi pour pouvoir utiliser DScaler, vu que sur mon ordi principal je ne peux pas). Avec un autre filtre ça ne plante pas. Le crash se produit DANS DScaler ... D'où difficulté à trouver l'origine du problème. Gingko From gingko_pouchintv at nospam.homelinux.org Thu Oct 4 00:49:57 2007 From: gingko_pouchintv at nospam.homelinux.org (Gingko) Date: Thu, 4 Oct 2007 00:49:57 +0200 Subject: [Pouchintv-dev] r86 : question References: <20071003205913.04F9B5F2A5@mail.baysse.fr> <470405DE.10100@baysse.fr> Message-ID: <000b01c8060f$b8c7ff50$0a00a8c0@gilles> ----- Original Message ----- From: "Laurent Baysse" To: "Liste utilisée par les développeurs" Sent: Wednesday, October 03, 2007 11:13 PM Subject: Re: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r86 - trunk >> * remplacement de quelques chaines de caracteres de char* en wchar_t*; Petite question, au fil de l'examen des modifications : Quel intérêt de convertir de char * en wchar_t * des chaînes de caractères dont on sait pertinemment qu'elles ne contiendront jamais de caractères qui justifient d'être stockés sur 16 bits ? Dans "AddLineToList", par exemple, fonction que j'avais ajouté moi-même, j'avais intentionnellement choisi de ne pas mettre les caractères en 16 bits pour cette raison ... Gingko From laurent at baysse.fr Thu Oct 4 10:18:40 2007 From: laurent at baysse.fr (Laurent Baysse) Date: Thu, 4 Oct 2007 10:18:40 +0200 (CEST) Subject: [Pouchintv-dev] r86 : question In-Reply-To: <000b01c8060f$b8c7ff50$0a00a8c0@gilles> References: <20071003205913.04F9B5F2A5@mail.baysse.fr> <470405DE.10100@baysse.fr> <000b01c8060f$b8c7ff50$0a00a8c0@gilles> Message-ID: <4353.90.5.173.240.1191485920.squirrel@mail.baysse.fr> Le Jeu 4 octobre 2007 00:49, Gingko a écrit : > > ----- Original Message ----- > From: "Laurent Baysse" > To: "Liste utilisée par les développeurs" > Sent: Wednesday, October 03, 2007 11:13 PM > Subject: Re: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r86 - trunk > > >>> * remplacement de quelques chaines de caracteres de char* en wchar_t*; > > Petite question, au fil de l'examen des modifications : > > Quel intérêt de convertir de char * en wchar_t * des chaînes de caractères > dont on sait pertinemment qu'elles ne contiendront jamais de caractères > qui > justifient d'être stockés sur 16 bits ? > > Dans "AddLineToList", par exemple, fonction que j'avais ajouté moi-même, > j'avais intentionnellement choisi de ne pas mettre les caractères en 16 > bits > pour cette raison ... > > Gingko > Pour une raison toute simple: Windows NT3.5, NT4, 2000, XP ou Vista utilisent en interne (api, affichage dans les menus, etc...) des chaines de caractères unicodes, donc, si on lui fournis déjà des caractères sur 16 bits, il n'aura pas à les reconvertir par derrière. Voilà pour l'explication... -- Laurent ....ooo...(°_°)...ooo.... From gingko_pouchintv at nospam.homelinux.org Thu Oct 4 11:58:13 2007 From: gingko_pouchintv at nospam.homelinux.org (Gingko) Date: Thu, 4 Oct 2007 11:58:13 +0200 Subject: [Pouchintv-dev] r86 : question References: <20071003205913.04F9B5F2A5@mail.baysse.fr><470405DE.10100@baysse.fr> <000b01c8060f$b8c7ff50$0a00a8c0@gilles> <4353.90.5.173.240.1191485920.squirrel@mail.baysse.fr> Message-ID: <000601c8066d$13f367e0$0a00a8c0@gilles> ----- Original Message ----- From: "Laurent Baysse" To: "Liste utilisée par les développeurs" Sent: Thursday, October 04, 2007 10:18 AM Subject: Re: [Pouchintv-dev] r86 : question > Pour une raison toute simple: > > Windows NT3.5, NT4, 2000, XP ou Vista utilisent en interne (api, affichage > dans les menus, etc...) des chaines de caractères unicodes, donc, si on > lui fournis déjà des caractères sur 16 bits, il n'aura pas à les > reconvertir par derrière. Voilà pour l'explication... > > > -- > Laurent Est-ce que c'est vraiment gênant qu'il ait besoin de les reconvertir ? On consomme des octets inutilement, d'un autre côté ... Gingko From pouchintv-svn at baysse.fr Thu Oct 4 18:08:33 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Thu, 4 Oct 2007 18:08:33 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r87 - trunk Message-ID: <20071004160833.AA2335F2A5@mail.baysse.fr> Author: gingko Date: 2007-10-04 18:08:33 +0200 (Thu, 04 Oct 2007) New Revision: 87 Modified: trunk/base.h trunk/graph.cpp trunk/ini.cpp trunk/main.cpp Log: Correctif pour le plantage qui se produisait ?\195?\160 la fin d'un scan des cha?\195?\174nes si scan au d?\195?\169marrage. Correctif pour le curseur qui ne disparaissait plus correctement. Correctif pour les noms de cha?\195?\174nes qui n'apparais- saient plus dans le menu. Correctif pour le d?\195?\169marrage minimis?\195?\169 qui ne marchait plus correctement. Int?\195?\169gration de la partie du patch de R_One qui permet l'activation du VMR9. Le VMR9 est cependant laiss?\195?\169 d?\195?\169sactiv?\195?\169. La lecture des cha?\195?\174nes est faite plus t?\195?\180t pour pouvoir d?\195?\169cider de l'?\195?\169tat (minimis?\195?\169, etc..) de la fen?\195?\170tre en fonction de son existence ou pas. Modified: trunk/base.h =================================================================== --- trunk/base.h 2007-10-03 20:59:12 UTC (rev 86) +++ trunk/base.h 2007-10-04 16:08:33 UTC (rev 87) @@ -3,6 +3,15 @@ #define BASE_H #pragma once +// Utiliser VMR9 +#define USE_VMR9 0 + +/* Pour éviter les problèmes de compatibilité entre qedit.h et vrm9.h */ + +#ifndef __D3DRM_H__ +#define __D3DRM_H__ +#endif + #define WIN32_LEAN_AND_MEAN #include #include @@ -17,6 +26,11 @@ #include +#if USE_VMR9 +# include +# include +#endif + #include #include @@ -45,9 +59,6 @@ // Enregistrer DShow #define LOG_DSHOW 0 -// Utiliser VMR9 -#define USE_VMR9 0 - // Nombre max de chaines #define NB_MAX_PISTES 32 @@ -77,9 +88,6 @@ #if USE_VMR9 -#include -#include - #define MyIVMRWindowlessControl IVMRWindowlessControl9 #define MyIID_IVMRWindowlessControl IID_IVMRWindowlessControl9 #define MyCLSID_VideoMixingRenderer CLSID_VideoMixingRenderer9 @@ -100,6 +108,8 @@ #define MyVMRMode_Windowless VMR9Mode_Windowless +#define MyVMRMode_Renderless VMR9Mode_Renderless + #define MyMixingPrefs (MixerPref9_NoDecimation | MixerPref9_BiLinearFiltering | MixerPref9_RenderTargetYUV) #else // #if USE_VMR9 @@ -248,7 +258,8 @@ etf_normal, // normal avec bordures etf_noborders, // normal sans bordures etf_maximized, // maximisé (avec bordures) - etf_fullscreen // plein écran (sans bordures) + etf_fullscreen, // plein écran (sans bordures) + etf_minimized // minimisée (en icône ou pas) }; #endif // #ifndef BASE_H Modified: trunk/graph.cpp =================================================================== --- trunk/graph.cpp 2007-10-03 20:59:12 UTC (rev 86) +++ trunk/graph.cpp 2007-10-04 16:08:33 UTC (rev 87) @@ -415,13 +415,18 @@ return 1; } +#if USE_VMR9 + pVMRConfig->SetRenderingMode(MyVMRMode_Windowless); +#else pVMRConfig->SetRenderingMode(MyVMRMode_Renderless); if (use_vmr_deinterlace) pVMRConfig->SetNumberOfStreams(1); +#endif pVMRConfig->Release(); } +#if !USE_VMR9 // Modif R_One - à revérifier { IVMRSurfaceAllocatorNotify * pNotify; hr = pVMR->QueryInterface(&pNotify); @@ -528,6 +533,7 @@ } } } +#endif // #if !USE_VMR9 hr = pVMR->QueryInterface(&pVMRControl); @@ -538,9 +544,10 @@ pVMRControl->SetVideoClippingWindow(hWnd); +#if !USE_VMR9 pVMRControl->SetColorKey(colorKey); +#endif - { MyIVMRAspectRatioControl * pARC; hr = pVMR->QueryInterface(&pARC); Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-03 20:59:12 UTC (rev 86) +++ trunk/ini.cpp 2007-10-04 16:08:33 UTC (rev 87) @@ -584,6 +584,7 @@ {L"Sans menus", etf_noborders}, {L"Maximisée", etf_maximized}, {L"Plein écran", etf_fullscreen}, + {L"Minimisée", etf_minimized}, {NULL, 0} // -> terminateur }; Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-10-03 20:59:12 UTC (rev 86) +++ trunk/main.cpp 2007-10-04 16:08:33 UTC (rev 87) @@ -119,6 +119,7 @@ bool use_msn = false; bool on_top = false; bool use_ac3 = false; +bool cmd_minimize = false; // TRUE si "-minimize" en option ligne de commande bool suspend_minimized = false; bool minimize_system_tray = false; bool is_vista = false; @@ -217,7 +218,11 @@ // Flag mis à TRUE si on est en mode plein écran, // ET que le curseur de la souris est temporairement visible. -static bool showing_cursor_in_full_screen = false; +enum EtatCurseur { + etc_normal, // Mode normal, allumé + etc_fullscreen_on, // Mode plein écran, allumé + etc_fullscreen_off // Mode plein écran, éteint +} etat_curseur; long DiffTime(SYSTEMTIME time1, SYSTEMTIME time2) { // Fonction qui retourne la différence time1 - time2, convertie en millisecondes. @@ -344,16 +349,15 @@ } } -static void set_timer_cursor() +static void change_etat_curseur(EtatCurseur nouvel_etat) { - if (!showing_cursor_in_full_screen) - ShowCursor(TRUE); - - showing_cursor_in_full_screen = true; - - // Laisse affiché un nombre de secondes défini par DUREE_CURSEUR - SetTimer(hWnd, TIMER_CURSOR, DUREE_CURSEUR, NULL); - + if (nouvel_etat != etat_curseur) { + if (etat_curseur!=etc_fullscreen_off && nouvel_etat==etc_fullscreen_off) + ShowCursor(FALSE); + else if (etat_curseur==etc_fullscreen_off && nouvel_etat!=etc_fullscreen_off) + ShowCursor(TRUE); + etat_curseur = nouvel_etat; + } } static void set_timer_osd() @@ -642,21 +646,22 @@ bool _recording = recording(); for (size_t i=0; i= (int)Canaux.size()) { nouvelleChaine = 0; @@ -2542,6 +2572,7 @@ HWND hWndInsertAfter = HWND_TOP; bool change = false; RECT rect = {0, 0, 0, 0}; + EtatCurseur nouveau_curseur = etc_normal; // si pas changé après GetWindowPlacement(hWnd, &wpl); @@ -2583,6 +2614,13 @@ if (remove_borders()) change = true; + nouveau_curseur = etc_fullscreen_on; + break; + case etf_minimized: + nouveau_style |= WS_OVERLAPPEDWINDOW; + newShowCmd = SW_SHOWMINIMIZED; + if (restore_borders()) + change = true; } if (nouveau_style != style_courant) { @@ -2611,6 +2649,8 @@ SetWindowPos(hWnd, hWndInsertAfter, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, wPosFlags); } + + change_etat_curseur(nouveau_curseur); } static void mute() @@ -3803,8 +3843,8 @@ // Gestion du timer qui supprime le curseur en mode plein écran, s'il n'a pas été déplacé // depuis le délai programmé. KillTimer(hWnd, TIMER_CURSOR); - showing_cursor_in_full_screen = false; - ShowCursor(FALSE); + if (etat_curseur==etc_fullscreen_on) + change_etat_curseur(etc_fullscreen_off); break; case TIMER_RECORD_START: @@ -3926,15 +3966,10 @@ switch(lParam) { case WM_LBUTTONDBLCLK: if (IsMinimized(hwnd)) { - if (pVMRControl == NULL) { - int res = init_vmr(); - change_frequence(Canaux[chaineCourante].frequence); - zappe_index(chaineCourante); - if (res) { - erreur(L"Erreur lors de la création du VMR"); - return -1; - } - } + if (!do_init_vmr()) + return -1; + change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire + zappe_index(chaineCourante); if (suspend_minimized) rebranche(); ShowWindow(hWnd, SW_SHOW); @@ -4041,9 +4076,12 @@ case etf_normal: case etf_noborders: mouse_move(wParam, lParam); + change_etat_curseur(etc_normal); break; case etf_fullscreen: - set_timer_cursor(); + change_etat_curseur(etc_fullscreen_on); + // Laisse affiché un nombre de secondes défini par DUREE_CURSEUR + SetTimer(hWnd, TIMER_CURSOR, DUREE_CURSEUR, NULL); // ... default: lRet = DefWindowProc(hwnd, uMsg, wParam, lParam); @@ -4065,15 +4103,10 @@ ShowWindow(hWnd, SW_HIDE); break; case SC_RESTORE: - if (pVMRControl == NULL) { - int res = init_vmr(); - change_frequence(Canaux[chaineCourante].frequence); - zappe_index(chaineCourante); - if (res) { - erreur(L"Erreur lors de la création du VMR"); - return -1; - } - } + if (!do_init_vmr()) + return -1; + change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire + zappe_index(chaineCourante); myprintf(L"WM_SYSCOMMAND restore\n"); if (suspend_minimized) rebranche(); @@ -4158,6 +4191,7 @@ //HWND hidden_hwnd; HWND hwnd; + cmd_minimize = strcmp(lpCmdLine, "-minimize")==0; hInst = hInstance; CreateMutex(NULL, TRUE, szAppName); @@ -4354,8 +4388,21 @@ // Rétablissement de la priorité de traitement sauvée dans la configuration : set_priority(configPriority); + // Ajustements de l'état de départ de la fenêtre : + if (lit_chaines()!=0 || Canaux.size()==0) { + // Pas question d'utiliser un état de fenêtre sauvegardé dans la config + // ou de tourner en mode minimisé si aucune chaîne n'a encore été détectée + cmd_minimize = false; + configState = etf_normal; + } else if (cmd_minimize) { + configState = etf_minimized; + } else if (configState == etf_minimized) { + // Ignorer la sauvegarde de l'état minimisé (vérifier si c'est adéquat) + configState = etf_normal; + } + // show and update main window - if (!strcmp(lpCmdLine, "-minimize")) { + if (cmd_minimize) { ShowWindow(hwnd, SW_MINIMIZE); UpdateWindow(hwnd); if (minimize_system_tray) @@ -4387,13 +4434,14 @@ } while (!config_ok); // On a lancé avec le paramètre demandant de masquer la fenêtre - if (!strcmp(lpCmdLine, "-minimize")) { + if (cmd_minimize) { myprintf(L"minimize\n"); if(suspend_minimized) { debranche(); } } else { - int res = init_vmr(); + if (!do_init_vmr()) + return -1; /* Force le changement de fréquence, sans quoi on a un écran noir au démarrage avec le tuner USB Toshiba PX1256E-1TVH */ for (int i=0; i<(int)Canaux.size(); i++) { @@ -4403,11 +4451,6 @@ } } change_frequence(Canaux[chaineCourante].frequence); - if (res) - { - erreur(L"Erreur lors de la création du VMR"); - return -1; - } } mainMenu = GetMenu(hwnd); From laurent at baysse.fr Thu Oct 4 19:39:33 2007 From: laurent at baysse.fr (Laurent Baysse) Date: Thu, 04 Oct 2007 19:39:33 +0200 Subject: [Pouchintv-dev] =?utf-8?q?Question_d=27icones_r=C3=A9gionales?= Message-ID: <47052555.2060704@baysse.fr> Bonsoir à tous, juste une petite question: Que pensez-vous d'incorporer à Pouchin TV Mod les icones des chaines régionales (repository, version publiée, zip, setup, ?) -- Laurent From pouchintv-svn at baysse.fr Fri Oct 5 10:59:33 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Fri, 5 Oct 2007 10:59:33 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r88 - trunk Message-ID: <20071005085933.A2B255F2A5@mail.baysse.fr> Author: gingko Date: 2007-10-05 10:59:32 +0200 (Fri, 05 Oct 2007) New Revision: 88 Modified: trunk/Hyperlinks.cpp trunk/base.h trunk/epg.cpp trunk/epgfilter.cpp trunk/graph.cpp trunk/ini.cpp trunk/main.cpp trunk/main.h trunk/pmtfilter.cpp Log: Il y avait toujours un probl?\195?\168me avec les ic?\195?\180nes des cha?\195?\174nes (le rechargement apr?\195?\168s scan faisait appara?\195?\174tre toutes les cha?\195?\174nes deux fois). J'en ai profit?\195?\169 pour r?\195?\169organiser ce chargement fa?\195?\167on POO, et ne l'effectuer qu'au moment de la premi?\195?\168re construction du menu. Renommage de certaines variables globales fr?\195?\169quemment utilis?\195?\169es afin de mieux faire ressortir le fait qu'on est en train d'utiliser une variable globale, et ?\195?\169viter les risques de collisions avec des variables locales de m?\195?\170me nom : hWnd devient hMainWnd hInst devient hAppInstance mainMenu devient hMainMenu Ces trois variables sont maintenant d?\195?\169clar?\195?\169es "extern" dans "main.h" (une seule l'?\195?\169tait auparavant) Toutes les variables locales de type "HWND hwnd" sont en revanche renomm?\195?\169es en hWnd. Suppression d'un appel ?\195?\160 update_all_menus dans InitDshow, parce qu'il faisait doublon. Modified: trunk/Hyperlinks.cpp =================================================================== --- trunk/Hyperlinks.cpp 2007-10-04 16:08:33 UTC (rev 87) +++ trunk/Hyperlinks.cpp 2007-10-05 08:59:32 UTC (rev 88) @@ -21,9 +21,9 @@ #pragma warning(disable:4244) #pragma warning(disable:4312) -LRESULT CALLBACK _HyperlinkParentProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK _HyperlinkParentProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WNDPROC pfnOrigProc = (WNDPROC) GetProp(hwnd, PROP_ORIGINAL_PROC); + WNDPROC pfnOrigProc = (WNDPROC) GetProp(hWnd, PROP_ORIGINAL_PROC); switch (message) { @@ -35,7 +35,7 @@ BOOL fHyperlink = (NULL != GetProp(hwndCtl, PROP_STATIC_HYPERLINK)); if (fHyperlink) { - LRESULT lr = CallWindowProc(pfnOrigProc, hwnd, message, wParam, lParam); + LRESULT lr = CallWindowProc(pfnOrigProc, hWnd, message, wParam, lParam); SetTextColor(hdc, RGB(0, 0, 192)); return lr; } @@ -44,59 +44,59 @@ } case WM_DESTROY: { - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)pfnOrigProc); - RemoveProp(hwnd, PROP_ORIGINAL_PROC); + SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)pfnOrigProc); + RemoveProp(hWnd, PROP_ORIGINAL_PROC); break; } } - return CallWindowProc(pfnOrigProc, hwnd, message, wParam, lParam); + return CallWindowProc(pfnOrigProc, hWnd, message, wParam, lParam); } -LRESULT CALLBACK _HyperlinkProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK _HyperlinkProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WNDPROC pfnOrigProc = (WNDPROC) GetProp(hwnd, PROP_ORIGINAL_PROC); + WNDPROC pfnOrigProc = (WNDPROC) GetProp(hWnd, PROP_ORIGINAL_PROC); switch (message) { case WM_DESTROY: { - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) pfnOrigProc); - RemoveProp(hwnd, PROP_ORIGINAL_PROC); + SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) pfnOrigProc); + RemoveProp(hWnd, PROP_ORIGINAL_PROC); - HFONT hOrigFont = (HFONT) GetProp(hwnd, PROP_ORIGINAL_FONT); - SendMessage(hwnd, WM_SETFONT, (WPARAM) hOrigFont, 0); - RemoveProp(hwnd, PROP_ORIGINAL_FONT); + HFONT hOrigFont = (HFONT) GetProp(hWnd, PROP_ORIGINAL_FONT); + SendMessage(hWnd, WM_SETFONT, (WPARAM) hOrigFont, 0); + RemoveProp(hWnd, PROP_ORIGINAL_FONT); - HFONT hFont = (HFONT) GetProp(hwnd, PROP_UNDERLINE_FONT); + HFONT hFont = (HFONT) GetProp(hWnd, PROP_UNDERLINE_FONT); DeleteObject(hFont); - RemoveProp(hwnd, PROP_UNDERLINE_FONT); + RemoveProp(hWnd, PROP_UNDERLINE_FONT); - RemoveProp(hwnd, PROP_STATIC_HYPERLINK); + RemoveProp(hWnd, PROP_STATIC_HYPERLINK); break; } case WM_MOUSEMOVE: { - if (GetCapture() != hwnd) + if (GetCapture() != hWnd) { - HFONT hFont = (HFONT) GetProp(hwnd, PROP_UNDERLINE_FONT); - SendMessage(hwnd, WM_SETFONT, (WPARAM) hFont, FALSE); - InvalidateRect(hwnd, NULL, FALSE); - SetCapture(hwnd); + HFONT hFont = (HFONT) GetProp(hWnd, PROP_UNDERLINE_FONT); + SendMessage(hWnd, WM_SETFONT, (WPARAM) hFont, FALSE); + InvalidateRect(hWnd, NULL, FALSE); + SetCapture(hWnd); } else { RECT rect; - GetWindowRect(hwnd, &rect); + GetWindowRect(hWnd, &rect); POINT pt = { LOWORD(lParam), HIWORD(lParam) }; - ClientToScreen(hwnd, &pt); + ClientToScreen(hWnd, &pt); if (!PtInRect(&rect, pt)) { - HFONT hFont = (HFONT) GetProp(hwnd, PROP_ORIGINAL_FONT); - SendMessage(hwnd, WM_SETFONT, (WPARAM) hFont, FALSE); - InvalidateRect(hwnd, NULL, FALSE); + HFONT hFont = (HFONT) GetProp(hWnd, PROP_ORIGINAL_FONT); + SendMessage(hWnd, WM_SETFONT, (WPARAM) hFont, FALSE); + InvalidateRect(hWnd, NULL, FALSE); ReleaseCapture(); } } @@ -109,7 +109,7 @@ } } - return CallWindowProc(pfnOrigProc, hwnd, message, wParam, lParam); + return CallWindowProc(pfnOrigProc, hWnd, message, wParam, lParam); } BOOL ConvertStaticToHyperlink(HWND hwndCtl) Modified: trunk/base.h =================================================================== --- trunk/base.h 2007-10-04 16:08:33 UTC (rev 87) +++ trunk/base.h 2007-10-05 08:59:32 UTC (rev 88) @@ -236,7 +236,14 @@ WORD pmt_pid; Emission prog1; Emission prog2; +private: HBITMAP hImage; +public: + // + // Constructeur : + Chaine() : hImage(NULL) {} + // + HBITMAP ChargeIcone(); }; struct Langue { Modified: trunk/epg.cpp =================================================================== --- trunk/epg.cpp 2007-10-04 16:08:33 UTC (rev 87) +++ trunk/epg.cpp 2007-10-05 08:59:32 UTC (rev 88) @@ -234,7 +234,7 @@ if(DiffTime(programme.debut, prog.fin) <= 0 && DiffTime(programme.fin, prog.debut) >= 0) { strcpy(buffer, "Chevauchement des horaires avec "); strcat(buffer, programme.nom); - MessageBoxA(hWnd, buffer, NULL, MB_ICONERROR); + MessageBoxA(hMainWnd, buffer, NULL, MB_ICONERROR); return 1;} } Modified: trunk/epgfilter.cpp =================================================================== --- trunk/epgfilter.cpp 2007-10-04 16:08:33 UTC (rev 87) +++ trunk/epgfilter.cpp 2007-10-05 08:59:32 UTC (rev 88) @@ -263,7 +263,8 @@ } // passe par le thread graphique pour updater, sinon ça plante - if (chaineEit == chaineCourante) PostMessage(hWnd, WM_USER, 0, 0); + if (chaineEit == chaineCourante) + PostMessage(hMainWnd, WM_USER, 0, 0); offset += len; } Modified: trunk/graph.cpp =================================================================== --- trunk/graph.cpp 2007-10-04 16:08:33 UTC (rev 87) +++ trunk/graph.cpp 2007-10-05 08:59:32 UTC (rev 88) @@ -542,7 +542,7 @@ return 1; } - pVMRControl->SetVideoClippingWindow(hWnd); + pVMRControl->SetVideoClippingWindow(hMainWnd); #if !USE_VMR9 pVMRControl->SetColorKey(colorKey); Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-04 16:08:33 UTC (rev 87) +++ trunk/ini.cpp 2007-10-05 08:59:32 UTC (rev 88) @@ -108,6 +108,55 @@ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } +HBITMAP cherche_icone(LPCWSTR dir, LPCSTR nom) +{ + wchar_t pathName[MAX_PATH]; + WIN32_FIND_DATA file_data; + HBITMAP hImage = NULL; + + // Concaténation chemin + chaîne + swprintf_s(pathName, _countof(pathName), L"%s\\Icones\\%S.bmp", dir, nom); + + HANDLE handle = FindFirstFile(pathName, &file_data); + if (handle != INVALID_HANDLE_VALUE) { + // Fichier trouvé. + hImage = (HBITMAP)LoadImage(NULL, pathName, IMAGE_BITMAP, + TAILLE_IMAGE_CHAINE, TAILLE_IMAGE_CHAINE, LR_LOADFROMFILE | LR_LOADTRANSPARENT); + FindClose(handle); + } + + return hImage; +} + +HBITMAP Chaine::ChargeIcone() +{ + if (hImage==INVALID_HANDLE_VALUE) + return NULL; + + if (hImage==NULL) { + /** + * Charge les bitmaps des chaînes + **/ + NomProtege nom_canal(nom, '_'); + + hImage = cherche_icone(pouchindir_conf, nom_canal.nom); + + if (hImage == NULL) { + // Le fichier n'a pas été trouvé dans le dossier des configs. + // Recherche dans le dossier de Pouchin TV Mod + + hImage = cherche_icone(pouchindir_prog, nom_canal.nom); + if (hImage == NULL) { + // Toujours pas trouvé : on met INVALID_HANDLE_VALUE pour se rappeler de ne plus le + // rechercher avant le prochain lancement du programme. + hImage = (HBITMAP)INVALID_HANDLE_VALUE; + } + } + } + + return hImage; +} + void lit_fichier_scan(wchar_t * ville) { wchar_t fileName[MAX_PATH]; @@ -117,7 +166,8 @@ UINT freq_offset = GetPrivateProfileInt(ville, L"Offset", 167, fileName); if (freq_offset != 166 && wcsstr(nom_tuner, L"Hauppauge") != NULL) { - int res = MessageBox(hWnd, L"L'offset recommandé pour une carte Hauppauge est 166.\nVoulez vous utiliser 166 ?", + int res = MessageBox(hMainWnd, + L"L'offset recommandé pour une carte Hauppauge est 166.\nVoulez vous utiliser 166 ?", L"Carte Hauppauge", MB_YESNO | MB_ICONQUESTION); if (res == IDYES) @@ -125,7 +175,8 @@ } if (freq_offset != 167 && wcsstr(nom_tuner, L"Cinergy") != NULL) { - int res = MessageBox(hWnd, L"L'offset recommandé pour une carte Cinergy est 167.\nVoulez vous utiliser 167 ?", + int res = MessageBox(hMainWnd, + L"L'offset recommandé pour une carte Cinergy est 167.\nVoulez vous utiliser 167 ?", L"Carte Cinergy", MB_YESNO | MB_ICONQUESTION); if (res == IDYES) @@ -401,40 +452,6 @@ pNode->getStr(var2, canal.autre[i].lang); } - /** - * Charge les bitmaps des chaînes - **/ - wchar_t image_prog[MAX_PATH], image_conf[MAX_PATH]; - - // Concaténation des chemins + chaine - NomProtege nom(canal.nom, '_'); - - swprintf_s(image_prog, _countof(image_prog), L"%s\\Icones\\%S.bmp", pouchindir_prog, nom.nom); - swprintf_s(image_conf, _countof(image_conf), L"%s\\Icones\\%S.bmp", pouchindir_conf, nom.nom); - - WIN32_FIND_DATA file_data; - HANDLE handle = FindFirstFile(image_conf, &file_data); - - if (handle == INVALID_HANDLE_VALUE) { - // Le fichier n'a pas été trouvé dans le dossier des configs. - // Recherche dans le dossier de Pouchin TV Mod - - handle = FindFirstFile(image_prog, &file_data); - if (handle != INVALID_HANDLE_VALUE) { - // Fichier trouvé. - canal.hImage = (HBITMAP)LoadImage(NULL, image_prog, IMAGE_BITMAP, TAILLE_IMAGE_CHAINE, TAILLE_IMAGE_CHAINE, LR_LOADFROMFILE | LR_LOADTRANSPARENT); - FindClose(handle); - } else { - // Aucune image créée - canal.hImage = NULL; - } - - } else { - // Fichier trouvé dans le dossier de configuration - canal.hImage = (HBITMAP)LoadImage(NULL, image_conf, IMAGE_BITMAP, TAILLE_IMAGE_CHAINE, TAILLE_IMAGE_CHAINE, LR_LOADFROMFILE | LR_LOADTRANSPARENT); - FindClose(handle); - } - Canaux.push_back(canal); delete pNode; @@ -660,9 +677,9 @@ save_config_bool(ini_use_all_width, use_all_width); save_config_bool(ini_etirer_video, etirer_video); save_config_bool(ini_use_vmr_deinterlace, use_vmr_deinterlace); - save_config_assoc(ini_etat_fenetre, aWStateTable, etat_fenetre(hWnd)); + save_config_assoc(ini_etat_fenetre, aWStateTable, etat_fenetre(hMainWnd)); save_config_int(ini_zoom_ratio, zoom_ratio); - save_config_winpos(ini_position_fenetre, hWnd); + save_config_winpos(ini_position_fenetre, hMainWnd); #if USE_CONSOLE==1 save_config_winpos(ini_position_console, GetConsoleWindow()); #endif // #if USE_CONSOLE==1 Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-10-04 16:08:33 UTC (rev 87) +++ trunk/main.cpp 2007-10-05 08:59:32 UTC (rev 88) @@ -55,12 +55,12 @@ // Windows globals, defines, and prototypes wchar_t szAppName[]=L"Pouchin TV Mod"; -HWND hWnd; +HINSTANCE hAppInstance; +HWND hMainWnd; +HMENU hMainMenu; static HWND hStatus; static HWND hSignalDlg = NULL; static HWND hRecordDlg = NULL; -static HINSTANCE hInst; -static HMENU mainMenu; static NOTIFYICONDATA niData; wchar_t filtreMPEG2[256]; @@ -204,7 +204,7 @@ void erreur(const wchar_t * chaine) { - MessageBox(hWnd, chaine, NULL, MB_ICONERROR); + MessageBox(hMainWnd, chaine, NULL, MB_ICONERROR); } #define TIMER_NUMBER 123 @@ -246,12 +246,12 @@ * 0 en cas d'échec **/ int ExtraitRcdataResource(LPCWSTR nom_resource, RcdataResource *resource) { - HRSRC hRcdataResource = FindResource(hInst, nom_resource, RT_RCDATA); + HRSRC hRcdataResource = FindResource(hAppInstance, nom_resource, RT_RCDATA); if (hRcdataResource != NULL) { - resource->taille = SizeofResource(hInst, hRcdataResource); + resource->taille = SizeofResource(hAppInstance, hRcdataResource); // Charge la ressource identifiée - HGLOBAL hRcdataCharge = LoadResource(hInst, hRcdataResource); + HGLOBAL hRcdataCharge = LoadResource(hAppInstance, hRcdataResource); if (hRcdataCharge != NULL) { // Bloque la ressource en mémoire pour utilisation @@ -343,7 +343,7 @@ temps_avant_enreg = USER_TIMER_MINIMUM; myprintf(L"Temps avant enregistrement : %i mS\n", temps_avant_enreg); - SetTimer(hWnd, TIMER_RECORD_START, temps_avant_enreg, NULL); + SetTimer(hMainWnd, TIMER_RECORD_START, temps_avant_enreg, NULL); // On indique qu'un timer est placée pour cet enregistrement Programmes[next_record].planifie = true; } @@ -363,10 +363,10 @@ static void set_timer_osd() { if (!is_vista) { - RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } // Laisse affiché un nombre de secondes défini par DUREE_OSD - SetTimer(hWnd, TIMER_OSD, DUREE_OSD, NULL); + SetTimer(hMainWnd, TIMER_OSD, DUREE_OSD, NULL); } @@ -436,14 +436,14 @@ static void change_priority(DWORD prio) { set_priority(prio); - update_priority_menu(hWnd); + update_priority_menu(hMainWnd); save_config(); } static void update_coords(void) { RECT rcDest; // Get the window client area. - GetClientRect(hWnd, &rcDest); + GetClientRect(hMainWnd, &rcDest); if (hStatus != NULL) { RECT rect; @@ -500,10 +500,10 @@ if (recording()) { // Icone d'enregistrement - hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_REC)); + hIcon = LoadIcon(hAppInstance, MAKEINTRESOURCE(IDI_ICON_REC)); } else { // Icone normale - hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_PROG_ICON)); + hIcon = LoadIcon(hAppInstance, MAKEINTRESOURCE(IDI_PROG_ICON)); } // On définit l'icone dans le systray @@ -646,7 +646,7 @@ bool _recording = recording(); for (size_t i=0; iSetCallback(NULL, 0); enregistrements_actuels[grab].chaine = -1; - update_menu_recording(hWnd); - update_chaines_menu(hWnd); + update_menu_recording(hMainWnd); + update_chaines_menu(hMainWnd); } /** @@ -874,19 +875,19 @@ HMENU pop = CreatePopupMenu(); - if (from_tray_icon && !IsMinimized(hWnd)) { + if (from_tray_icon && !IsMinimized(hMainWnd)) { // Ajoute d'autres infos si venant du tray AppendMenu(pop, MF_STRING, SC_MINIMIZE, L"Ré&duire la fenêtre"); AppendMenu(pop, MF_SEPARATOR, NULL, NULL); } - HMENU copie0 = copie_menu(GetSubMenu(mainMenu, 0)); - HMENU copie1 = copie_menu(GetSubMenu(mainMenu, 1)); - HMENU copie2 = copie_menu(GetSubMenu(mainMenu, 2)); - HMENU copie3 = copie_menu(GetSubMenu(mainMenu, 3)); - HMENU copie4 = copie_menu(GetSubMenu(mainMenu, 4)); - HMENU copie5 = copie_menu(GetSubMenu(mainMenu, 5)); + HMENU copie0 = copie_menu(GetSubMenu(hMainMenu, 0)); + HMENU copie1 = copie_menu(GetSubMenu(hMainMenu, 1)); + HMENU copie2 = copie_menu(GetSubMenu(hMainMenu, 2)); + HMENU copie3 = copie_menu(GetSubMenu(hMainMenu, 3)); + HMENU copie4 = copie_menu(GetSubMenu(hMainMenu, 4)); + HMENU copie5 = copie_menu(GetSubMenu(hMainMenu, 5)); AppendMenu(pop, MF_STRING | MF_POPUP, (UINT_PTR)copie0, L"Fichier"); AppendMenu(pop, MF_STRING | MF_POPUP, (UINT_PTR)copie1, L"Filtres"); @@ -897,11 +898,11 @@ update_all_menus_popup(pop); - SetForegroundWindow(hWnd); + SetForegroundWindow(hMainWnd); ShowCursor(TRUE); - TrackPopupMenuEx(pop, TPM_LEFTALIGN | TPM_LEFTBUTTON, pos.x, pos.y, hWnd, NULL); + TrackPopupMenuEx(pop, TPM_LEFTALIGN | TPM_LEFTBUTTON, pos.x, pos.y, hMainWnd, NULL); ShowCursor(FALSE); @@ -1018,7 +1019,7 @@ const Chaine & canal_courant = Canaux[chaineCourante]; if (!is_vista) { - RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } if (hStatus != NULL) { @@ -1063,13 +1064,13 @@ msndata.dwData = 0x547; msndata.lpData = &buffer; msndata.cbData = (lstrlenW(buffer)*2)+2; - SendMessage(msnui, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&msndata); + SendMessage(msnui, WM_COPYDATA, (WPARAM)hMainWnd, (LPARAM)&msndata); } } //tip systray if(minimize_system_tray && first_pass) { - //niData.hWnd = hWnd; + //niData.hWnd = hMainWnd; wchar_t tip[128]; swprintf_s(tip, _countof(tip), L"%S - %S", canal_courant.nom, canal_courant.prog1.nom); lstrcpy(niData.szTip, tip); @@ -1101,7 +1102,7 @@ } sonCourant=new_son; - update_pistes_menu(hWnd); + update_pistes_menu(hMainWnd); } void zappe_index(int nouvelle_chaine) @@ -1177,7 +1178,7 @@ hr = pMapPmt->MapPID(1, &pid, MEDIA_MPEG2_PSI); myprintf(L"%?erreur pid pmt, hr=0x%08x\n", FAILED(hr), hr); - update_all_menus(hWnd); + update_all_menus(hMainWnd); update_status_bar(); } @@ -1276,7 +1277,7 @@ identifie = LogonUser(username, NULL, mdp, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &session); while (!identifie) { wcscpy(mdp, L""); - ok = DialogBox(hInst, MAKEINTRESOURCE(IDD_PASWD), hWnd, PaswdDialogProc)==0; + ok = DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_PASWD), hMainWnd, PaswdDialogProc)==0; if (!ok) break; @@ -1625,7 +1626,6 @@ RecupereNomVille(hComboItem); sauve_chaines(); // sauvegarde les chaînes dans le ini save_config(); // sauvegarde la configuration (le nom de ville peut avoir changé) - lit_chaines(); // recharge les chaines (et les icones en plus) EndDialog(hwndDlg, 0); // 0 = pas d'erreur return TRUE; case MAKELONG(IDC_COMBO_VILLE, CBN_SELCHANGE): @@ -2098,7 +2098,7 @@ static int scanne(void) { - int res = (int)DialogBox(hInst, MAKEINTRESOURCE(IDD_SCAN), hWnd, ScanProc); + int res = (int)DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_SCAN), hMainWnd, ScanProc); if (res!=0) return res; @@ -2129,13 +2129,13 @@ static void switch_on_top(void) { // pas de sens en plein écran, et puis menu pas visible... - if (etat_fenetre(hWnd)==etf_fullscreen) + if (etat_fenetre(hMainWnd)==etf_fullscreen) return; on_top = !on_top; - switch_etat_fenetre(etat_fenetre(hWnd)); + switch_etat_fenetre(etat_fenetre(hMainWnd)); - HMENU hMenu = GetMenu(hWnd); + HMENU hMenu = GetMenu(hMainWnd); if (hMenu != NULL) { MENUITEMINFO info; @@ -2187,9 +2187,11 @@ if (Canaux.size() > 0) zappe_index(nouvelleChaine); + else + update_all_menus(hMainWnd); // -> sinon, "zappe_index" le fait déjà + set_volume(volumeCourant); - update_all_menus(hWnd); nouvelleChaine = 0; @@ -2260,9 +2262,12 @@ // Ajoute l'icone de Pouchin TV Mod // Charge l'image - HANDLE icone_pouchin = LoadImage(hInst, MAKEINTRESOURCE(IDB_BITMAP), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS); + HANDLE icone_pouchin = + LoadImage(hAppInstance, MAKEINTRESOURCE(IDB_BITMAP), IMAGE_BITMAP, 0, 0, + LR_CREATEDIBSECTION | LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS); // Envoie l'image à l'élément dans la fenêtre - SendDlgItemMessage(hwndDlg, IDC_ABOUT_ICON, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM) icone_pouchin); + SendDlgItemMessage(hwndDlg, IDC_ABOUT_ICON, STM_SETIMAGE, + (WPARAM)IMAGE_BITMAP, (LPARAM) icone_pouchin); // Libère (fuites mémoires) FreeResource(icone_pouchin); } @@ -2318,7 +2323,7 @@ case IDOK: // Clic sur le bouton OK stop_all_records(); - update_menu_recording(hWnd); + update_menu_recording(hMainWnd); EndDialog(hwndDlg, 1); return TRUE; @@ -2434,7 +2439,7 @@ ShowCursor(TRUE); hr = OleCreatePropertyFrame( - hWnd, + hMainWnd, 10, 10, nom, @@ -2479,11 +2484,11 @@ case IDOK: grab = getGrabberChaine(chaineCourante); if (grab>=0) { - KillTimer(hWnd, TIMER_RECORD_END_BASE+grab); + KillTimer(hMainWnd, TIMER_RECORD_END_BASE+grab); SendDlgItemMessage(hwndDlg, IDC_DELAYED_STOP, DTM_GETSYSTEMTIME, 0, (LPARAM)&time); delayed = ((time.wHour*60 + time.wMinute)*60 + time.wSecond)*1000; - SetTimer(hWnd, TIMER_RECORD_END_BASE+grab, delayed, NULL); + SetTimer(hMainWnd, TIMER_RECORD_END_BASE+grab, delayed, NULL); } case IDCANCEL: EndDialog(hwndDlg, 0); @@ -2499,7 +2504,7 @@ static void traite_numero(int nb) { nouvelleChaine = nouvelleChaine * 10 + nb; - SetTimer(hWnd, TIMER_NUMBER, 1000, NULL); + SetTimer(hMainWnd, TIMER_NUMBER, 1000, NULL); last_chaine = GetTickCount(); set_timer_osd(); @@ -2507,7 +2512,7 @@ static void create_status_bar(void) { - //hStatus = CreateStatusWindow(WS_CHILD | WS_VISIBLE, L"chaîne", hwnd, 41234); + //hStatus = CreateStatusWindow(WS_CHILD | WS_VISIBLE, L"chaîne", hMainWnd, 41234); // Create the status bar. hStatus = CreateWindowExA( @@ -2516,9 +2521,9 @@ NULL, // no text when first created WS_CHILD | WS_VISIBLE, // creates a child window 0, 0, 0, 0, // ignores size and position - hWnd, // handle to parent window + hMainWnd, // handle to parent window (HMENU) 41234, // child window identifier - hInst, // handle to application instance + hAppInstance, // handle to application instance NULL); // no window creation data @@ -2539,8 +2544,8 @@ hStatus = NULL; change = true; } - if (GetMenu(hWnd)!=NULL) { - SetMenu(hWnd, NULL); + if (GetMenu(hMainWnd)!=NULL) { + SetMenu(hMainWnd, NULL); change = true; } return change; @@ -2554,8 +2559,8 @@ create_status_bar(); change = true; } - if (GetMenu(hWnd)==NULL) { - SetMenu(hWnd, mainMenu); + if (GetMenu(hMainWnd)==NULL) { + SetMenu(hMainWnd, hMainMenu); change = true; } return change; @@ -2565,7 +2570,7 @@ void switch_etat_fenetre(EtatsFenetre nouvel_etat) { WINDOWPLACEMENT wpl = {sizeof(wpl)}; - LONG_PTR style_courant = GetWindowLongPtr(hWnd, GWL_STYLE); + LONG_PTR style_courant = GetWindowLongPtr(hMainWnd, GWL_STYLE); LONG_PTR nouveau_style = style_courant; // EtatsFenetre etat_courant = etat_fenetre(style_courant); UINT wPosFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED; @@ -2574,7 +2579,7 @@ RECT rect = {0, 0, 0, 0}; EtatCurseur nouveau_curseur = etc_normal; // si pas changé après - GetWindowPlacement(hWnd, &wpl); + GetWindowPlacement(hMainWnd, &wpl); UINT newShowCmd = wpl.showCmd; @@ -2606,7 +2611,7 @@ { MONITORINFO mi = {sizeof(MONITORINFO)}; - HMONITOR hMon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); + HMONITOR hMon = MonitorFromWindow(hMainWnd, MONITOR_DEFAULTTONEAREST); GetMonitorInfo(hMon, &mi); rect = mi.rcMonitor; @@ -2624,14 +2629,14 @@ } if (nouveau_style != style_courant) { - SetWindowLongPtr(hWnd, GWL_STYLE, nouveau_style); + SetWindowLongPtr(hMainWnd, GWL_STYLE, nouveau_style); change = true; } if (on_top) { wPosFlags &= ~SWP_NOZORDER; hWndInsertAfter = HWND_TOPMOST; - if (!change && GetTopWindow(NULL) != hWnd) + if (!change && GetTopWindow(NULL) != hMainWnd) change = true; } else { wPosFlags &= ~SWP_NOZORDER; @@ -2641,12 +2646,12 @@ if (newShowCmd != wpl.showCmd) { wpl.showCmd = newShowCmd; - SetWindowPlacement(hWnd, &wpl); - //ShowWindow(hWnd, newShowCmd); // provoque une animation de fenêtre gênante + SetWindowPlacement(hMainWnd, &wpl); + //ShowWindow(hMainWnd, newShowCmd); // provoque une animation de fenêtre gênante } if (change) { - SetWindowPos(hWnd, hWndInsertAfter, + SetWindowPos(hMainWnd, hWndInsertAfter, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, wPosFlags); } @@ -2668,7 +2673,7 @@ pBas->Release(); if (!is_vista) { - RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } } @@ -2780,7 +2785,7 @@ if ((wParam & MK_LBUTTON)!=0 ) { RECT rect; - GetWindowRect(hWnd, &rect); + GetWindowRect(hMainWnd, &rect); int x_screen = LOWORD(lParam) + rect.left; int y_screen = HIWORD(lParam) + rect.top; @@ -2789,7 +2794,8 @@ int dx = x_screen - last_x; int dy = y_screen - last_y; - MoveWindow(hWnd, rect.left+dx, rect.top+dy, rect.right-rect.left, rect.bottom-rect.top, TRUE); + MoveWindow(hMainWnd, rect.left+dx, rect.top+dy, + rect.right-rect.left, rect.bottom-rect.top, TRUE); } last_x = x_screen; @@ -2803,10 +2809,10 @@ /** * Fonction sélectionnant le répertoire initial lors de la demande d'un dossier **/ -static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) +static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { if(uMsg == BFFM_INITIALIZED) - SendMessage(hwnd, BFFM_SETSELECTION, 1, lpData); + SendMessage(hWnd, BFFM_SETSELECTION, 1, lpData); return 0; } @@ -2936,7 +2942,7 @@ if (beta.major > major || (beta.major == major && beta.minor > minor) || (beta.major == major && beta.minor == minor && _stricmp(beta.rev, version) > 0)) { - MessageBox(hWnd, + MessageBox(hMainWnd, L"Une nouvelle version de développement est disponible sur le site.", L"Nouvelle version !", MB_OK | MB_ICONINFORMATION); @@ -2957,7 +2963,7 @@ if (release.major > major || (release.major == major && release.minor > minor) || (release.major == major && release.minor == minor && _stricmp(release.rev, (char*)rcVersion.contenu) > 0)) { - MessageBox(hWnd, + MessageBox(hMainWnd, L"Une nouvelle version est disponible sur le site.", L"Nouvelle version !", MB_OK | MB_ICONINFORMATION); @@ -2966,18 +2972,18 @@ } } - MessageBox(hWnd, + MessageBox(hMainWnd, L"Vous disposez actuellement de la dernière version de Pouchin TV Mod.", L"Aucune mise à jour disponible", MB_ICONINFORMATION); } else { - MessageBox(hWnd, + MessageBox(hMainWnd, L"Le fichier de mise à jour n'est pas valide. Veuillez réessayer ultérieurement", L"Erreur lors de la mise à jour", MB_ICONERROR); } } else { - MessageBox(hWnd, + MessageBox(hMainWnd, L"Une erreur s'est produite lors de la recherche de mise à jour.\n\n" L"Veuillez vérifier votre connexion internet, et réessayez ultérieurement !", L"Erreur lors de la mise à jour", MB_ICONERROR); @@ -3007,7 +3013,7 @@ sonCourant = 0; } - if (!IsMinimized(hWnd) && suspend_minimized) + if (!IsMinimized(hMainWnd) && suspend_minimized) rebranche(); ISampleGrabberCB * pCallback = NULL; @@ -3071,16 +3077,16 @@ // On mémorise ce qu'il faut faire à la fin de l'enregistrement programmé enregistrements_actuels[grab].apres = prog.after; - update_menu_recording(hWnd); - update_chaines_menu(hWnd); + update_menu_recording(hMainWnd); + update_chaines_menu(hMainWnd); // Vérif si l'heure de début est déjà passée SYSTEMTIME localtime; GetLocalTime(&localtime); if (DiffTime(prog.debut, localtime) < 0) - SetTimer(hWnd, TIMER_RECORD_END_BASE+grab, DiffTime(prog.fin, localtime), NULL); + SetTimer(hMainWnd, TIMER_RECORD_END_BASE+grab, DiffTime(prog.fin, localtime), NULL); else - SetTimer(hWnd, TIMER_RECORD_END_BASE+grab, DiffTime(prog.fin, prog.debut), NULL); + SetTimer(hMainWnd, TIMER_RECORD_END_BASE+grab, DiffTime(prog.fin, prog.debut), NULL); // Recherche si l'enregistrement doit être répété bool repetition = false; @@ -3165,9 +3171,9 @@ // Arrêt de pouchinTV ? if (after == apr_quitter) { - if (IsMinimized(hWnd)) - ShowWindow(hWnd, SW_RESTORE); - DestroyWindow(hWnd); + if (IsMinimized(hMainWnd)) + ShowWindow(hMainWnd, SW_RESTORE); + DestroyWindow(hMainWnd); } // Arrêt de l'ordinateur if (after == apr_eteindrePC) { @@ -3218,7 +3224,7 @@ RECT rect; // Récupère la taille de la fenêtre - GetClientRect(hWnd, &rect); + GetClientRect(hMainWnd, &rect); // Si la barre de status est affichée, retire sa hauteur à la taille de la fenêtre if (hStatus != NULL) { @@ -3297,7 +3303,7 @@ if (show_chaine) { if(nouvelleChaine > 256) { nouvelleChaine = 0; - KillTimer(hWnd, TIMER_NUMBER); + KillTimer(hMainWnd, TIMER_NUMBER); } else if (nouvelleChaine > 0) { SetTextAlign(hdc, TA_RIGHT); @@ -3402,8 +3408,8 @@ enregistrements_actuels[grab].apres = apr_rien; pSample[grab]->SetCallback(pCallback, 0); - update_menu_recording(hWnd); - update_chaines_menu(hWnd); + update_menu_recording(hMainWnd); + update_chaines_menu(hMainWnd); } } @@ -3426,8 +3432,8 @@ enregistrements_actuels[grab].apres = apr_rien; pSample[grab]->SetCallback(pCallback, 0); - update_menu_recording(hWnd); - update_chaines_menu(hWnd); + update_menu_recording(hMainWnd); + update_chaines_menu(hMainWnd); } } @@ -3443,8 +3449,8 @@ pSample[grab]->SetCallback(pCallback, 0); - update_menu_recording(hWnd); - update_chaines_menu(hWnd); + update_menu_recording(hMainWnd); + update_chaines_menu(hMainWnd); } } #endif // #if USE_RECORD_STREAM @@ -3456,7 +3462,7 @@ wchar_t display_name[MAX_PATH]; - bi.hwndOwner = hWnd; // Handle de la fenêtre + bi.hwndOwner = hMainWnd; // Handle de la fenêtre bi.pszDisplayName = display_name; // Variable recevant le dossier sélectionné bi.lpszTitle = title; // Message à afficher dans la fenêtre bi.ulFlags = BIF_RETURNONLYFSDIRS; // N'afiche que les dossiers @@ -3485,16 +3491,16 @@ case IDM_QUIT: if (recording()) { // Si on enregistre affiche la fenêtre de confirmation - if (DialogBox(hInst, MAKEINTRESOURCE(IDD_CLOSE_CONFIRM), hWnd, ConfirmCloseProc) == 0) + if (DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_CLOSE_CONFIRM), hMainWnd, ConfirmCloseProc) == 0) break; // On a appuyé sur Annuler, donc, on ne quitte pas } - //if (IsMinimized(hwnd)) - // ShowWindow(hwnd, SW_RESTORE); // Est-ce bien nécessaire, puisque justement, on quitte ? (Gingko) - DestroyWindow(hWnd); + //if (IsMinimized(hMainWnd)) + // ShowWindow(hMainWnd, SW_RESTORE); // Est-ce bien nécessaire, puisque justement, on quitte ? (Gingko) + DestroyWindow(hMainWnd); break; case IDM_CONFIG: - DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), hWnd, ConfigDialogProc); + DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_CONFIG), hMainWnd, ConfigDialogProc); break; case IDM_CHANNELS: { @@ -3502,9 +3508,10 @@ if (!rechercheEncours) { rechercheEncours = true; int res = scanne(); - update_chaines_menu(hWnd); // ajoute les chaînes dans le menu + update_chaines_menu(hMainWnd); // ajoute les chaînes dans le menu if (res==-1) - MessageBox(hWnd, L"Annulation : La configuration précédente des chaînes a été rétablie", + MessageBox(hMainWnd, + L"Annulation : La configuration précédente des chaînes a été rétablie", L"Recherche annulée", MB_ICONINFORMATION | MB_OK); rechercheEncours = false; } @@ -3512,14 +3519,15 @@ break; } case IDM_ABOUT: - DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hWnd, AboutDialogProc); + DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_ABOUT), hMainWnd, AboutDialogProc); break; case IDM_DELAYED_RECORD: if (hRecordDlg) BringWindowToTop(hRecordDlg); else { - hRecordDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DELAYED_RECORD), hWnd, RecordDialogProc); + hRecordDlg = CreateDialog(hAppInstance, + MAKEINTRESOURCE(IDD_DELAYED_RECORD), hMainWnd, RecordDialogProc); ShowWindow(hRecordDlg, SW_SHOW); } break; @@ -3566,7 +3574,7 @@ update_coords(); last_zoom = GetTickCount(); if (is_vista) { - RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } set_timer_osd(); break; @@ -3574,7 +3582,7 @@ case IDM_DEFAULT_ZOOM: zoom_ratio = 100; use_all_width = false; - update_all_width_and_ar_menu(hWnd); + update_all_width_and_ar_menu(hMainWnd); update_coords(); last_zoom = GetTickCount(); set_timer_osd(); @@ -3583,17 +3591,17 @@ case IDM_STRETCH: use_all_width = !use_all_width; if (etirer_video && use_all_width) etirer_video = false; - update_all_width_and_ar_menu(hWnd); + update_all_width_and_ar_menu(hMainWnd); update_coords(); - RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); break; case IDM_NOAR: etirer_video = !etirer_video; if (etirer_video && use_all_width) use_all_width = false; - update_all_width_and_ar_menu(hWnd); + update_all_width_and_ar_menu(hMainWnd); update_coords(); - RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); break; case IDM_SCREENSHOT: @@ -3622,13 +3630,13 @@ case IDM_DELAYED_STOP: ShowCursor(TRUE); - DialogBox(hInst, MAKEINTRESOURCE(IDD_DELAYED_STOP), hWnd, DelayedStopDialogProc); + DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_DELAYED_STOP), hMainWnd, DelayedStopDialogProc); ShowCursor(FALSE); break; case IDM_FULLSCREEN: { static EtatsFenetre sauve_etat = etf_normal; - EtatsFenetre etat_courant = etat_fenetre(hWnd); + EtatsFenetre etat_courant = etat_fenetre(hMainWnd); if (etat_courant==etf_fullscreen) switch_etat_fenetre(sauve_etat); @@ -3659,7 +3667,7 @@ if (hEpgDlg) BringWindowToTop(hEpgDlg); else { - hEpgDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_EPG), hWnd, EpgDialogProc); + hEpgDlg = CreateDialog(hAppInstance, MAKEINTRESOURCE(IDD_EPG), hMainWnd, EpgDialogProc); ShowWindow(hEpgDlg, SW_SHOW); } break; @@ -3668,7 +3676,7 @@ if (hSignalDlg) BringWindowToTop(hSignalDlg); else { - hSignalDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SIGNAL), hWnd, SignalDialogProc); + hSignalDlg = CreateDialog(hAppInstance, MAKEINTRESOURCE(IDD_SIGNAL), hMainWnd, SignalDialogProc); ShowWindow(hSignalDlg, SW_SHOW); } break; @@ -3691,40 +3699,40 @@ msndata.dwData = 0x547; msndata.lpData = L"\\0Music\\00\\0\\0\\0\\0\\0\\0"; msndata.cbData = (lstrlenW((wchar_t *) msndata.lpData)*2)+2; - SendMessage(msnui, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&msndata); + SendMessage(msnui, WM_COPYDATA, (WPARAM)hMainWnd, (LPARAM)&msndata); } } - update_msn_menu(hWnd); + update_msn_menu(hMainWnd); break; case IDM_AC3_DEF: use_ac3 = !use_ac3; - update_ac3_menu(hWnd); + update_ac3_menu(hMainWnd); break; case IDM_SUSPEND: suspend_minimized = !suspend_minimized; - update_suspend_menu(hWnd); + update_suspend_menu(hMainWnd); break; case IDM_SYSTEM_TRAY: minimize_system_tray = !minimize_system_tray; - update_system_tray_menu(hWnd); + update_system_tray_menu(hMainWnd); // sert plus a rien ? - //ShowWindow(hWnd, SW_HIDE); + //ShowWindow(hMainWnd, SW_HIDE); if (minimize_system_tray) { - SetWindowLongPtr(hWnd, GWL_EXSTYLE, 0); - niData.hWnd = hWnd; + SetWindowLongPtr(hMainWnd, GWL_EXSTYLE, 0); + niData.hWnd = hMainWnd; wchar_t tip[128]; const Chaine & canal_courant = Canaux[chaineCourante]; swprintf_s(tip, _countof(tip), L"%S - %S", canal_courant.nom, canal_courant.prog1.nom); lstrcpy(niData.szTip, tip); Shell_NotifyIcon(NIM_ADD,&niData); } else { - SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW); + SetWindowLongPtr(hMainWnd, GWL_EXSTYLE, WS_EX_APPWINDOW); Shell_NotifyIcon(NIM_DELETE,&niData); } - //ShowWindow(hWnd, SW_SHOW); + //ShowWindow(hMainWnd, SW_SHOW); break; case IDM_VOL_AUG: @@ -3774,11 +3782,11 @@ // On a demandé une recherche de mise à jour ? // Lance un timer car, si problème de connexion, fige Pouchin TV Mod sinon :( - SetTimer(hWnd, TIMER_UPDATE, USER_TIMER_MINIMUM, NULL); + SetTimer(hMainWnd, TIMER_UPDATE, USER_TIMER_MINIMUM, NULL); break; case SC_MINIMIZE: - SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, NULL); + SendMessage(hMainWnd, WM_SYSCOMMAND, SC_MINIMIZE, NULL); break; default: @@ -3802,21 +3810,21 @@ // chaîne au clavier. Le timer est nécessaire pour permettre de taper un numéro de chaîne // à plusieurs chiffres (tous les chiffres sont considérés saisis à l'issue du délai // du timer). - KillTimer(hWnd, TIMER_NUMBER); + KillTimer(hMainWnd, TIMER_NUMBER); chaine_saisie(); break; case TIMER_UPDATE: - KillTimer(hWnd, TIMER_UPDATE); + KillTimer(hMainWnd, TIMER_UPDATE); do_web_update(); break; case TIMER_BORDER: // Gestion du timer qui permet, lors d'un clic sur l'écran, de distinguer entre le passage en plein // écran et l'activation / désactivation des bordures de fenêtre. - KillTimer(hWnd, TIMER_BORDER); + KillTimer(hMainWnd, TIMER_BORDER); - switch (etat_fenetre(hWnd)) { + switch (etat_fenetre(hMainWnd)) { case etf_normal: switch_etat_fenetre(etf_noborders); break; @@ -3833,23 +3841,23 @@ case TIMER_OSD: // Gestion du timer supprimant l'affichage OSD après expiration du délai. - KillTimer(hWnd, TIMER_OSD); + KillTimer(hMainWnd, TIMER_OSD); if (!is_vista) { - RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } break; case TIMER_CURSOR: // Gestion du timer qui supprime le curseur en mode plein écran, s'il n'a pas été déplacé // depuis le délai programmé. - KillTimer(hWnd, TIMER_CURSOR); + KillTimer(hMainWnd, TIMER_CURSOR); if (etat_curseur==etc_fullscreen_on) change_etat_curseur(etc_fullscreen_off); break; case TIMER_RECORD_START: // Gestion du timer de début d'enregistrement : - KillTimer(hWnd, TIMER_RECORD_START); + KillTimer(hMainWnd, TIMER_RECORD_START); grab = getGrabber(); if (grab == -1) { @@ -3871,7 +3879,7 @@ /** * main window procedure **/ -static LRESULT WINAPI MainWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static POINT coord_down; static int tray = 0; @@ -3881,7 +3889,7 @@ case WM_CREATE: { myprintf(L"create\n"); - hWnd = hwnd; + hMainWnd = hWnd; if (/*(GetWindowLong(hWnd, GWL_HWNDPARENT) == NULL) &&*/ minimize_system_tray && tray == 0) { // on ne crée qu'une icone dans la zone de notification @@ -3896,12 +3904,12 @@ case WM_PAINT: if (!is_vista) { PAINTSTRUCT ps; - HDC hdc = BeginPaint(hwnd, &ps); + HDC hdc = BeginPaint(hWnd, &ps); do_osd(hdc); - EndPaint(hwnd, &ps); + EndPaint(hWnd, &ps); } else { // if(!is_vista) // Laisse Windows traiter les messages sous Vista - lRet = DefWindowProc(hwnd, uMsg, wParam, lParam); + lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); } break; @@ -3919,7 +3927,7 @@ update_coords(); if (is_vista) { - RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } break; @@ -3929,14 +3937,14 @@ break; case WM_CLOSE: - //if (IsMinimized(hwnd)) - // ShowWindow(hwnd, SW_RESTORE); + //if (IsMinimized(hWnd)) + // ShowWindow(hWnd, SW_RESTORE); if (recording()) { // Si on enregistre affiche la fenêtre de confirmation - if (DialogBox(hInst, MAKEINTRESOURCE(IDD_CLOSE_CONFIRM), hwnd, ConfirmCloseProc) == 0) + if (DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_CLOSE_CONFIRM), hWnd, ConfirmCloseProc) == 0) break; // On a appuyé sur Annuler, donc, on ne quitte pas } - DestroyWindow(hwnd); + DestroyWindow(hWnd); break; case WM_DESTROY: @@ -3958,14 +3966,14 @@ case WM_MENUSELECT: // Au cas où une application externe aurait changé la priorité : if (get_priority()!=configPriority) - update_priority_menu(hwnd); - lRet = DefWindowProc(hwnd, uMsg, wParam, lParam); + update_priority_menu(hWnd); + lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); break; case MY_TRAY_ICON_MESSAGE: switch(lParam) { case WM_LBUTTONDBLCLK: - if (IsMinimized(hwnd)) { + if (IsMinimized(hWnd)) { if (!do_init_vmr()) return -1; change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire @@ -3980,7 +3988,7 @@ break; case WM_LBUTTONDOWN: - if (!IsMinimized(hwnd)) + if (!IsMinimized(hWnd)) SetForegroundWindow(hWnd); break; case WM_CONTEXTMENU: @@ -4049,8 +4057,8 @@ break; case WM_LBUTTONDBLCLK: - KillTimer(hwnd, TIMER_BORDER); - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDM_FULLSCREEN, 1), 0); + KillTimer(hWnd, TIMER_BORDER); + PostMessage(hWnd, WM_COMMAND, MAKELONG(IDM_FULLSCREEN, 1), 0); // évite de passer en mode bordures coord_down.x = -1; break; @@ -4068,11 +4076,11 @@ GetCursorPos(&newPos); if (newPos.x == coord_down.x && newPos.y == coord_down.y) - SetTimer(hwnd, TIMER_BORDER, DUREE_SWITCH_BORDER, NULL); + SetTimer(hWnd, TIMER_BORDER, DUREE_SWITCH_BORDER, NULL); break; } case WM_MOUSEMOVE: - switch (etat_fenetre(hwnd)) { + switch (etat_fenetre(hWnd)) { case etf_normal: case etf_noborders: mouse_move(wParam, lParam); @@ -4084,7 +4092,7 @@ SetTimer(hWnd, TIMER_CURSOR, DUREE_CURSEUR, NULL); // ... default: - lRet = DefWindowProc(hwnd, uMsg, wParam, lParam); + lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); } break; @@ -4098,7 +4106,7 @@ myprintf(L"WM_SYSCOMMAND minimize\n"); if (suspend_minimized) debranche(); - lRet = DefWindowProc(hwnd, uMsg, wParam, lParam); + lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); if (minimize_system_tray) ShowWindow(hWnd, SW_HIDE); break; @@ -4112,13 +4120,13 @@ rebranche(); if (minimize_system_tray) ShowWindow(hWnd, SW_SHOW); - lRet = DefWindowProc(hwnd, uMsg, wParam, lParam); + lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); break; case SC_MAXIMIZE: myprintf(L"WM_SYSCOMMAND maximize\n"); // ... default: - lRet = DefWindowProc(hwnd, uMsg, wParam, lParam); + lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); break; } break; @@ -4140,7 +4148,7 @@ break; default: - lRet = DefWindowProc(hwnd, uMsg, wParam, lParam); + lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); break; } @@ -4164,7 +4172,7 @@ swprintf_s(message, _countof(message), L"Le répertoire « %s », spécifié pour sauvegarder les %S, n'existe pas.\n\n" L"Voulez-vous le créer ?", dir, dirUsage); - if (MessageBox(hWnd, message, L"Dossier inexistant", MB_ICONQUESTION | MB_YESNO) == IDYES) { + if (MessageBox(hMainWnd, message, L"Dossier inexistant", MB_ICONQUESTION | MB_YESNO) == IDYES) { // On le crée donc if (!CreateDirectory(dir, NULL)) { // Erreur lors de la création du dossier @@ -4172,13 +4180,13 @@ swprintf_s(message, _countof(message), L"Une erreur est survenue lors de la création du répertoire.\n" L"Le nouveau répertoire pour les %S est :\n\n%s", dirUsage, dir); - MessageBox(hWnd, message, L"Erreur de création du dossier", MB_ICONEXCLAMATION); + MessageBox(hMainWnd, message, L"Erreur de création du dossier", MB_ICONEXCLAMATION); } } else { wcscpy_s(dir, dir_size, default_dir); swprintf_s(message, _countof(message), L"Le nouveau répertoire pour les %S est :\n\n%s", dirUsage, dir); - MessageBox(hWnd, message, L"Changement de dossier", MB_ICONINFORMATION); + MessageBox(hMainWnd, message, L"Changement de dossier", MB_ICONINFORMATION); } } } @@ -4188,11 +4196,11 @@ MSG msg; WNDCLASS wndclass; - //HWND hidden_hwnd; - HWND hwnd; + //HWND hHiddenWnd; + HWND hWnd; cmd_minimize = strcmp(lpCmdLine, "-minimize")==0; - hInst = hInstance; + hAppInstance = hInstance; CreateMutex(NULL, TRUE, szAppName); if (GetLastError() == ERROR_ALREADY_EXISTS) { @@ -4294,7 +4302,7 @@ /* on s'en sert plus pour l'instant // Create the frame - hidden_hwnd = CreateWindowEx(WS_EX_TOOLWINDOW, + hHiddenWnd = CreateWindowEx(WS_EX_TOOLWINDOW, szAppName, L"Hidden Window", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, @@ -4308,13 +4316,13 @@ NULL); // make sure window was created - if (!hidden_hwnd) { + if (!hHiddenWnd) { CoUninitialize(); return 0; } */ - hwnd = CreateWindowEx(0, + hWnd = CreateWindowEx(0, szAppName, L"Pouchin TV Mod", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, @@ -4328,7 +4336,7 @@ NULL); // make sure window was created - if (!hwnd) { + if (!hWnd) { CoUninitialize(); return 0; } @@ -4341,7 +4349,7 @@ // Si on minimise dans la zone système, n'affiche pas la fenêtre dans la barre des tâches if (!minimize_system_tray) { - SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW); + SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW); } // Comme marqué, on crée la barre de status de la fenêtre @@ -4403,21 +4411,21 @@ // show and update main window if (cmd_minimize) { - ShowWindow(hwnd, SW_MINIMIZE); - UpdateWindow(hwnd); + ShowWindow(hWnd, SW_MINIMIZE); + UpdateWindow(hWnd); if (minimize_system_tray) ShowWindow(hWnd, SW_HIDE); Sleep(5000); } else { - ShowWindow(hwnd, nCmdShow); - UpdateWindow(hwnd); + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); } bool config_ok = check_config(); do { if (!config_ok) { - if (DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), hWnd, ConfigDialogProc)!=IDOK) { + if (DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_CONFIG), hWnd, ConfigDialogProc)!=IDOK) { erreur(L"Configuration annulée.\nLe logiciel ne peut pas être exécuté."); return -1; } @@ -4453,7 +4461,7 @@ change_frequence(Canaux[chaineCourante].frequence); } - mainMenu = GetMenu(hwnd); + hMainMenu = GetMenu(hWnd); /** * Rétablit la fenêtre, en enlevant les bordures si Pouchin TV Mod a été @@ -4463,7 +4471,7 @@ switch_etat_fenetre(configState); #if USE_RECORD_STREAM - InsertMenuA(GetSubMenu(mainMenu, 5), 3, MF_BYPOSITION, IDM_RECORD_STREAM, + InsertMenuA(GetSubMenu(hMainMenu, 5), 3, MF_BYPOSITION, IDM_RECORD_STREAM, "Enregistrer le &multiplex\tCtrl+M"); #endif // #if USE_RECORD_STREAM Modified: trunk/main.h =================================================================== --- trunk/main.h 2007-10-04 16:08:33 UTC (rev 87) +++ trunk/main.h 2007-10-05 08:59:32 UTC (rev 88) @@ -10,7 +10,9 @@ extern int chaineCourante; extern long volumeCourant; -extern HWND hWnd; +extern HINSTANCE hAppInstance; +extern HWND hMainWnd; +extern HMENU hMainMenu; DWORD get_priority(); Modified: trunk/pmtfilter.cpp =================================================================== --- trunk/pmtfilter.cpp 2007-10-04 16:08:33 UTC (rev 87) +++ trunk/pmtfilter.cpp 2007-10-05 08:59:32 UTC (rev 88) @@ -115,7 +115,7 @@ sauve_chaines(); // dit de rezapper sur cette chaîne - PostMessage(hWnd, WM_USER+1, 0, 0); + PostMessage(hMainWnd, WM_USER+1, 0, 0); } } From gingko_pouchintv at nospam.homelinux.org Fri Oct 5 16:11:42 2007 From: gingko_pouchintv at nospam.homelinux.org (Gingko) Date: Fri, 5 Oct 2007 16:11:42 +0200 Subject: [Pouchintv-dev] Dialogues de configuration Message-ID: <002d01c80759$a806f090$0a00a8c0@gilles> Bonjour, Je veux juste vous informer que je suis en train de travailler sur un dialogue de configuration unifié de style "Property Sheet", reprenant de manière centralisée toutes les options de configuration qui sont actuellement dispersées dans les menus. À cette occasion, je crée une nouvelle paire de fichiers "config.h" et "config.cpp" dans lequel l'ensemble de ces éléments de configuration vont être gérés. Merci donc d'éviter de toucher aux éléments suivants : - ConfigDialogProc - ScanProc, ainsi que les fonctions liées à la recherche des chaînes - La configuration des répertoires vidéo et captures d'écrans - 4 items (au moins) du menu "Programme" seront également concernés. Nombre de fonctions liées plus ou moins exclusivement aux éléments ci-dessus vont sans doute être déplacées dans config.cpp également. Gingko From laurent at baysse.fr Sat Oct 6 09:49:27 2007 From: laurent at baysse.fr (Laurent Baysse) Date: Sat, 06 Oct 2007 09:49:27 +0200 Subject: [Pouchintv-dev] Dialogues de configuration In-Reply-To: <002d01c80759$a806f090$0a00a8c0@gilles> References: <002d01c80759$a806f090$0a00a8c0@gilles> Message-ID: <47073E07.7050301@baysse.fr> Gingko a écrit : > Bonjour, > > Je veux juste vous informer que je suis en train de travailler sur un dialogue de configuration unifié de style "Property Sheet", reprenant de manière centralisée toutes les options de configuration qui sont actuellement dispersées dans les menus. > > À cette occasion, je crée une nouvelle paire de fichiers "config.h" et "config.cpp" dans lequel l'ensemble de ces éléments de configuration vont être gérés. > > Merci donc d'éviter de toucher aux éléments suivants : > > - ConfigDialogProc > - ScanProc, ainsi que les fonctions liées à la recherche des chaînes > - La configuration des répertoires vidéo et captures d'écrans > - 4 items (au moins) du menu "Programme" seront également concernés. > > Nombre de fonctions liées plus ou moins exclusivement aux éléments ci-dessus vont sans doute être déplacées dans config.cpp également. > > Gingko > Salut, je ne vois qu'une contre indication à tout ça: le fichier "config.h" est habituellement utilisé pour configurer les options de compilation (defines pour le préproc). Je pense qu'il vaudrai mieux utiliser un nom style "configoptions.h" et "configoptions.cpp". Rien à dire sur le reste. -- Laurent From pouchintv-svn at baysse.fr Sat Oct 6 14:42:43 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Sat, 6 Oct 2007 14:42:43 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r89 - in trunk: . Icones Icones/Locales Message-ID: <20071006124243.6EB6A5F2A4@mail.baysse.fr> Author: lolo_32 Date: 2007-10-06 14:42:42 +0200 (Sat, 06 Oct 2007) New Revision: 89 Added: trunk/Icones/Locales/ trunk/Icones/Locales/ORLEANS TV.bmp Modified: trunk/Programme_Install.nsi trunk/ini.cpp trunk/main.cpp Log: * Ajout de l'icone de "Orlean TV" pour les chaines locales; * permet d'utiliser les fichiers de config dans le repertoire de PTVM Au lancement, PTVM verifie si le fichier "config.ini" existe dans "Application Data". S'il n'existe pas, il verifie dans le dossier de PTVM, et remplace donc, si trouve, pouchindir_conf par pouchindir_prog si le fichier "config.ini" existe; * la fonction copie_menu copie les menus de maniere recursive; * ajout du menu "Programme" aux choix possibles du menu contextuel; * creation de l'icone dans le systray juste avant la boucle de traitement des messages (evite d'avoir l'icone presente si l'on quitte sqns config, par exemple); * ne zappe plus de chaine si on est reduit, que l'on agrandie et que l'on ne suspend en reduit; * le mutex est cree au tout debut; * les positions des menus "Chaines" et "Pistes" sont determines en fonctionnement; * ajout d'une entree pour les icones locales dans le programme d'installation. Added: trunk/Icones/Locales/ORLEANS TV.bmp =================================================================== (Binary files differ) Property changes on: trunk/Icones/Locales/ORLEANS TV.bmp ___________________________________________________________________ Name: svn:mime-type + image/x-ms-bmp Modified: trunk/Programme_Install.nsi =================================================================== --- trunk/Programme_Install.nsi 2007-10-05 08:59:32 UTC (rev 88) +++ trunk/Programme_Install.nsi 2007-10-06 12:42:42 UTC (rev 89) @@ -227,14 +227,21 @@ SectionEnd -Section "Icônes des chaines françaises" Icones +SectionGroup /e "Icônes des chaines" Icones - SetOutPath "$INSTDIR\Icones" + Section "Françaises nationales" IconesFR + SetOutPath "$INSTDIR\Icones" + ;Ajout des icones + File "Icones\*.bmp" + SectionEnd - ;Ajout des icones - File "Icones\*.bmp" + Section "Françaises locales" IconesFRLocales + SetOutPath "$INSTDIR\Icones" + ;Ajout des icones des chaines locales + File "Icones\Locales\*.bmp" + SectionEnd -SectionEnd +SectionGroupEnd Function .onInit Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-05 08:59:32 UTC (rev 88) +++ trunk/ini.cpp 2007-10-06 12:42:42 UTC (rev 89) @@ -141,7 +141,8 @@ hImage = cherche_icone(pouchindir_conf, nom_canal.nom); - if (hImage == NULL) { + // Ne recherche que si le dossier de config est différent du dossier du programme + if (hImage == NULL && wcscmp(pouchindir_conf, pouchindir_prog) != 0) { // Le fichier n'a pas été trouvé dans le dossier des configs. // Recherche dans le dossier de Pouchin TV Mod @@ -655,9 +656,6 @@ void save_config(void) { - wcscpy_s(confPathName, _countof(confPathName), pouchindir_conf); - wcscat_s(confPathName, _countof(confPathName), config_file); - save_config_str(ini_tuner, nom_tuner); save_config_str(ini_receiver, nom_receiver); save_config_str(ini_filtre_MPEG2, filtreMPEG2); @@ -740,10 +738,30 @@ void load_config(void) { - wcscpy_s(confPathName, _countof(confPathName), pouchindir_conf); - wcscat_s(confPathName, _countof(confPathName), config_file); + wchar_t chemin_config[MAX_PATH]; + wcscpy_s(chemin_config, _countof(chemin_config), pouchindir_conf); + wcscat_s(chemin_config, _countof(chemin_config), config_file); + wcscpy_s(confPathName, _countof(confPathName), chemin_config); + + // Recherche si on a un fichier de config dans AppData load_config_str(ini_tuner, nom_tuner, _countof(nom_tuner)); + if (wcscmp(nom_tuner, L"") == 0) { + // Pas de tuner trouvé. On recherche dans le dossier courant + wcscpy_s(confPathName, _countof(confPathName), pouchindir_prog); + wcscat_s(confPathName, _countof(confPathName), config_file); + + load_config_str(ini_tuner, nom_tuner, _countof(nom_tuner)); + // Vérifie si on a une réponse + if(wcscmp(nom_tuner, L"") == 0) + // Comme fichier config.ini n'existe pas non plus, restauration du chemin vers config.ini + wcscpy_s(confPathName, _countof(confPathName), chemin_config); + else + // la config du tuner a été trouvée dans le répertoire de PTVM + // On change le répertoire de config vers celui su programme + wcscpy_s(pouchindir_conf, _countof(pouchindir_conf), pouchindir_prog); + } + load_config_str(ini_receiver, nom_receiver, _countof(nom_receiver)); load_config_str(ini_filtre_MPEG2, filtreMPEG2, _countof(filtreMPEG2)); load_config_str(ini_filtre_audio, filtreAudio, _countof(filtreAudio)); Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-10-05 08:59:32 UTC (rev 88) +++ trunk/main.cpp 2007-10-06 12:42:42 UTC (rev 89) @@ -597,12 +597,76 @@ } +/** + * Recherche le numéro du menu en enlevant les "&" le cas échéant + **/ +static int cherche_menu(const HMENU hMenu, LPCWSTR cherche_menu) +{ + LPWSTR cherche_strip = new wchar_t[wcslen(cherche_menu)+1]; + int ret = -1; + + if (wcspbrk(cherche_menu, L"&") != 0) { + UINT j=0; + for (UINT i=0; i=0 && wID<=100) { // cas changement chaîne @@ -3882,7 +3986,6 @@ static LRESULT WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static POINT coord_down; - static int tray = 0; LRESULT lRet = 0; switch (uMsg) { @@ -3890,14 +3993,6 @@ case WM_CREATE: { myprintf(L"create\n"); hMainWnd = hWnd; - - if (/*(GetWindowLong(hWnd, GWL_HWNDPARENT) == NULL) &&*/ minimize_system_tray && tray == 0) { - // on ne crée qu'une icone dans la zone de notification - tray = 1; - niData.hWnd = hWnd; - Shell_NotifyIcon(NIM_ADD,&niData); - } - break; } @@ -3976,10 +4071,11 @@ if (IsMinimized(hWnd)) { if (!do_init_vmr()) return -1; - change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire - zappe_index(chaineCourante); - if (suspend_minimized) + if (suspend_minimized) { rebranche(); + change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire + zappe_index(chaineCourante); + } ShowWindow(hWnd, SW_SHOW); ShowWindow(hWnd, SW_RESTORE); } else { @@ -4113,11 +4209,12 @@ case SC_RESTORE: if (!do_init_vmr()) return -1; - change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire - zappe_index(chaineCourante); + if (suspend_minimized) { + rebranche(); + change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire + zappe_index(chaineCourante); + } myprintf(L"WM_SYSCOMMAND restore\n"); - if (suspend_minimized) - rebranche(); if (minimize_system_tray) ShowWindow(hWnd, SW_SHOW); lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); @@ -4132,7 +4229,7 @@ break; case WM_CONTEXTMENU: - popup_menu(); + popup_menu(false); break; case WM_SETFOCUS: @@ -4193,27 +4290,26 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { + // Première chose à faire: + // Vérifier si une autre version ne fonctionne pas déjà + CreateMutex(NULL, TRUE, szAppName); + if (GetLastError() == ERROR_ALREADY_EXISTS) { + // Affiche la fenêtre de Pouchin TV Mod déjà lancée au premier plan + HWND hPouchintvmod = FindWindow(szAppName, L"Pouchin TV Mod"); + if (hPouchintvmod) { + SendMessage(hPouchintvmod, WM_SYSCOMMAND, SC_RESTORE, NULL); + SetForegroundWindow(hPouchintvmod); + } + return 0; + } MSG msg; WNDCLASS wndclass; - //HWND hHiddenWnd; HWND hWnd; cmd_minimize = strcmp(lpCmdLine, "-minimize")==0; hAppInstance = hInstance; - CreateMutex(NULL, TRUE, szAppName); - if (GetLastError() == ERROR_ALREADY_EXISTS) { - // Affiche la fenêtre de Pouchin TV Mod déjà lancée au premier plan - HWND pouchintvmod = FindWindow(szAppName, L"Pouchin TV Mod"); - BOOL ret = 0; - if (pouchintvmod) { - ret = SendMessage(pouchintvmod, WM_SYSCOMMAND, SC_RESTORE, NULL); - ret = SetForegroundWindow(pouchintvmod); - } - return 0; - } - // Récupère les dossiers de Pouchin TV Mod GetModuleFileName(NULL, pouchindir_prog, sizeof(pouchindir_prog)); for (size_t i = wcslen(pouchindir_prog) - 1; L'\\'!=pouchindir_prog[i]; i--) @@ -4255,12 +4351,6 @@ fclose(fop); } - // ** Supprimé car initialisé par constructeur, maintenant. - //for (int i=0; i Bonsoir à tous, je suis en train de réécrire l'implémentation des cartes DVB-T, pour un meilleur support des cartes, et pour une programmation objet ;) Mais j'ai pas trop de temps cette semaine, donc, je le livrerai lorsque tout sera OK -- Laurent From pouchintv-svn at baysse.fr Thu Oct 11 23:12:45 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Thu, 11 Oct 2007 23:12:45 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r90 - restreint Message-ID: <20071011211245.BF40C5F2C2@mail.baysse.fr> Author: lolo_32 Date: 2007-10-11 23:12:45 +0200 (Thu, 11 Oct 2007) New Revision: 90 Added: restreint/Ms Press - Programming DirectShow for Digital Video & TV.chm Log: Ajout de la documentation pour la programmation avec DirectShow aux fichiers restreints Added: restreint/Ms Press - Programming DirectShow for Digital Video & TV.chm =================================================================== (Binary files differ) Property changes on: restreint/Ms Press - Programming DirectShow for Digital Video & TV.chm ___________________________________________________________________ Name: svn:mime-type + application/octet-stream From pouchintv-svn at baysse.fr Fri Oct 12 10:26:21 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Fri, 12 Oct 2007 10:26:21 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r91 - trunk Message-ID: <20071012082621.52BF45F2BF@mail.baysse.fr> Author: gingko Date: 2007-10-12 10:26:20 +0200 (Fri, 12 Oct 2007) New Revision: 91 Modified: trunk/Pouchin TV.vcproj trunk/base.h trunk/graph.cpp trunk/graph.h trunk/ini.cpp trunk/ini.h trunk/main.cpp trunk/main.h trunk/res.rc trunk/resource.h trunk/search.cpp trunk/search.h Log: Cr?\195?\169ation d'une interface de configuration avec feuilles de propri?\195?\169t?\195?\169s, regroupant des ?\195?\169l?\195?\169ments qui se trouvaient pr?\195?\169c?\195?\169demment dans les menus, et constituant ainsi une base pour permettre d'impl?\195?\169menter un nombre beaucoup plus grand d'?\195?\169l?\195?\169ments configurables. Ajout d'une paire de fichiers "settings.h" et "settings.cpp" pour regrouper les ?\195?\169l?\195?\169ments de configuration concern?\195?\169s (ainsi que la recherche de cha?\195?\174nes). La gestion de l'ic?\195?\180ne de la zone de notification a ?\195?\169t?\195?\169 d?\195?\169plac?\195?\169e dans une nouvelle paire de fichiers "trayicon.h" et "trayicon.cpp", avec une interface style POO pour cette gestion. Am?\195?\169lioration (enfin, j'esp?\195?\168re) de la mise ?\195?\160 jour des menus. Utilisation de WM_RBUTTONUP ?\195?\160 la place de WM_RBUTTONDOWN pour d?\195?\169rouler le menu contextuel dans la zone de notifications : ceci ?\195?\169vite des corruptions d'affichage de ce menu ?\195?\160 cause du menu contextuel standard de Windows qui tend ?\195?\160 vouloir appara?\195?\174tre en m?\195?\170me temps. Ajout des ic?\195?\180nes de cha?\195?\174nes dans le projet, permettant ainsi d'utiliser l'?\195?\169diteur de Visual Studio pour modifier certaines d'entre elles, si besoin est. Un peu d'optimisation. Modified: trunk/Pouchin TV.vcproj =================================================================== --- trunk/Pouchin TV.vcproj 2007-10-11 21:12:45 UTC (rev 90) +++ trunk/Pouchin TV.vcproj 2007-10-12 08:26:20 UTC (rev 91) @@ -764,6 +764,14 @@ > + + + + @@ -838,6 +846,14 @@ > + + + + @@ -860,13 +876,149 @@ > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: trunk/base.h =================================================================== --- trunk/base.h 2007-10-11 21:12:45 UTC (rev 90) +++ trunk/base.h 2007-10-12 08:26:20 UTC (rev 91) @@ -246,11 +246,6 @@ HBITMAP ChargeIcone(); }; -struct Langue { - char code[8]; - wchar_t lang[32]; -}; - struct Frequence { WORD canal_no; long mhz; Modified: trunk/graph.cpp =================================================================== --- trunk/graph.cpp 2007-10-11 21:12:45 UTC (rev 90) +++ trunk/graph.cpp 2007-10-12 08:26:20 UTC (rev 91) @@ -1061,10 +1061,10 @@ // connect USB - hr = pGraph->AddFilter(pNetworkTuner, L"Clé USB"); + hr = pGraph->AddFilter(pNetworkTuner, L"Tuner USB"); if (FAILED(hr)) { - erreur(L"Clé USB pas inséré"); + erreur(L"Tuner USB pas inséré"); return 1; } Modified: trunk/graph.h =================================================================== --- trunk/graph.h 2007-10-11 21:12:45 UTC (rev 90) +++ trunk/graph.h 2007-10-12 08:26:20 UTC (rev 91) @@ -1,5 +1,5 @@ -int build_graph(void); +int build_graph(void); // retourne 0 = pas d'erreur, 1 = erreur void clean_dshow(void); int init_vmr(void); Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-11 21:12:45 UTC (rev 90) +++ trunk/ini.cpp 2007-10-12 08:26:20 UTC (rev 91) @@ -798,7 +798,7 @@ volumeCourant = load_config_int(ini_volume, 100) * 100 - 10000; } -void remplit_combo_ville(HWND hComboItem) +void remplit_villes(HWND hItm) { wchar_t strings[8192]; @@ -810,12 +810,12 @@ wchar_t * p = strings; - SendMessage(hComboItem, CB_ADDSTRING, 0, (LPARAM)L"Non précisée (scanne tous les canaux)"); + SendMessage(hItm, CB_ADDSTRING, 0, (LPARAM)L"Non précisée (scanne tous les canaux)"); while (*p != 0) { if (wcscmp(general, p)) { - SendMessage(hComboItem, CB_ADDSTRING, 0, (LPARAM)p); + SendMessage(hItm, CB_ADDSTRING, 0, (LPARAM)p); } // trouve le prochain 0 Modified: trunk/ini.h =================================================================== --- trunk/ini.h 2007-10-11 21:12:45 UTC (rev 90) +++ trunk/ini.h 2007-10-12 08:26:20 UTC (rev 91) @@ -6,7 +6,7 @@ void sauve_programmes(void); void save_config(void); void load_config(void); -void remplit_combo_ville(HWND hComboItem); +void remplit_villes(HWND hItm); void remplit_liste_programmes(HWND hdlg, int item); bool check_config(void); Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-10-11 21:12:45 UTC (rev 90) +++ trunk/main.cpp 2007-10-12 08:26:20 UTC (rev 91) @@ -32,9 +32,10 @@ #include #include "ini.h" +#include "settings.h" #include "parse.h" #include "search.h" - +#include "trayicon.h" #include "epg.h" #include "grabber.h" @@ -58,10 +59,11 @@ HINSTANCE hAppInstance; HWND hMainWnd; HMENU hMainMenu; +HICON hPrgIcon = NULL; // Icône normale du programme +HICON hRecIcon = NULL; // Icône utilisée en mode enregistrement static HWND hStatus; static HWND hSignalDlg = NULL; static HWND hRecordDlg = NULL; -static NOTIFYICONDATA niData; wchar_t filtreMPEG2[256]; wchar_t filtreAudio[256]; @@ -86,7 +88,6 @@ std::vector Canaux; std::vector Programmes; -std::vector Tab_Lang; int chaineCourante = -1; int sonCourant = 0; @@ -281,7 +282,7 @@ * * Renvoie 1 si on enregistre actuellement, 0 sinon **/ -static bool recording(void) +bool recording(void) { for (int i=0; iSetCallback(NULL, 0); enregistrements_actuels[grab].chaine = -1; - update_menu_recording(hMainWnd); - update_chaines_menu(hMainWnd); + update_record_menus(hMainWnd); } /** @@ -867,48 +787,13 @@ static void update_all_menus_popup(HMENU hMenu) { if (hMenu != NULL) { - _update_pistes_menu(hMenu); - _update_chaines_menu(hMenu); - - MENUITEMINFO info; - info.cbSize = sizeof(MENUITEMINFO); - info.fMask = MIIM_STATE; - - info.fState = use_all_width ? MFS_CHECKED : MFS_UNCHECKED; - - SetMenuItemInfo(hMenu, IDM_STRETCH, FALSE, &info); - - info.fState = etirer_video ? MFS_CHECKED : MFS_UNCHECKED; - - SetMenuItemInfo(hMenu, IDM_NOAR, FALSE, &info); - - info.fState = MFS_DISABLED; - - if (getGrabber() == -1 || getGrabberChaine(chaineCourante) != -1) { - info.fState = MFS_DISABLED; - } else { - info.fState = MFS_ENABLED; - } - - SetMenuItemInfo(hMenu, IDM_RECORD_CHANNEL_PS, FALSE, &info); - SetMenuItemInfo(hMenu, IDM_RECORD_CHANNEL_TS, FALSE, &info); - - if (getGrabberChaine(chaineCourante) != -1) { - info.fState = MFS_ENABLED; - } else { - info.fState = MFS_DISABLED; - } - SetMenuItemInfo(hMenu, IDM_STOP_RECORD, FALSE, &info); - SetMenuItemInfo(hMenu, IDM_DELAYED_STOP, FALSE, &info); -#if USE_RECORD_STREAM - // Désactive l'enregistrement du multiplex si un enregistrement est en cours - if (recording()) { - info.fState = MFS_DISABLED; - } else { - info.fState = MFS_ENABLED; - } - SetMenuItemInfo(hMenu, IDM_RECORD_STREAM, FALSE, &info); -#endif // #if USE_RECORD_STREAM + update_pistes_menu(hMenu); + update_chaines_menu(hMenu); + update_aspect_menus(hMenu); + update_ontop_menu(hMenu); + update_fullscreen_menu(hMenu); + update_menu_recording(hMenu); + update_mute_menu(hMenu); } } @@ -963,10 +848,10 @@ mnu.cbSize = sizeof(MENUITEMINFO); mnu.fMask = MIIM_BITMAP; if (!IsMinimized(hMainWnd)) { - AppendMenu(pop, MF_STRING, SC_MINIMIZE, L"Ré&duire la fenêtre"); + AppendMenu(pop, MF_STRING, IDM_MINIMIZE, L"Ré&duire la fenêtre"); mnu.hbmpItem = HBMMENU_POPUP_MINIMIZE; } else { - AppendMenu(pop, MF_STRING, SC_RESTORE, L"&Restaurer la fenêtre"); + AppendMenu(pop, MF_STRING, IDM_RESTORE, L"&Restaurer la fenêtre"); mnu.hbmpItem = HBMMENU_POPUP_RESTORE; if (suspend_minimized) @@ -977,25 +862,16 @@ AppendMenu(pop, MF_SEPARATOR, NULL, NULL); } -#define _copie_menu_vers_pop(position) \ - { \ - wchar_t nom_menu[256]; \ - HMENU contenu_copie; \ - contenu_copie = copie_menu(GetSubMenu(hMainMenu, position)); \ - GetMenuString(hMainMenu, position, nom_menu, _countof(nom_menu), MF_BYPOSITION); \ - AppendMenu(pop, MF_STRING | MF_POPUP, (UINT_PTR)contenu_copie, nom_menu); \ + // Copie des menus 0=Fichier, 1=Filtres, 2=Commandes, + // 3=Chaines, 4=Pistes, 5=Captures, 6=Programme. + for (int i=0; i<=6; i++) { + wchar_t nom_menu[64]; + HMENU contenu_copie = copie_menu(GetSubMenu(hMainMenu, i)); + + GetMenuString(hMainMenu, i, nom_menu, _countof(nom_menu), MF_BYPOSITION); + AppendMenu(pop, MF_STRING | MF_POPUP, (UINT_PTR)contenu_copie, nom_menu); } - _copie_menu_vers_pop(0); // Fichier - _copie_menu_vers_pop(1); // Filtres - _copie_menu_vers_pop(2); // Commandes - _copie_menu_vers_pop(3); // Chaines - _copie_menu_vers_pop(4); // Pistes - _copie_menu_vers_pop(5); // Captures - _copie_menu_vers_pop(6); // Programme - -#undef _copie_menu_vers_pop - // Met à jour les menus (chaînes + pistes) update_all_menus_popup(pop); @@ -1113,9 +989,27 @@ } +void update_systray_state() { + LONG_PTR ex_style = GetWindowLongPtr(hMainWnd, GWL_EXSTYLE); + LONG_PTR ex_style_save = ex_style; + + if (minimize_system_tray) { + // Si on minimise dans la zone système, alors on n'affiche + // pas la fenêtre dans la barre des tâches + ex_style &= ~WS_EX_APPWINDOW; + } else + ex_style |= WS_EX_APPWINDOW; + + if (ex_style != ex_style_save) { + //ShowWindow(hMainWnd, SW_HIDE); // sert plus a rien ? + SetWindowLongPtr(hMainWnd, GWL_EXSTYLE, ex_style); + niData.update_state(); + //ShowWindow(hMainWnd, SW_SHOW); + } +} + static void update_status_bar(void) { - static bool first_pass = false; const Chaine & canal_courant = Canaux[chaineCourante]; if (!is_vista) { @@ -1150,8 +1044,6 @@ #endif // #ifdef USE_LOGITECH_LCD if (use_msn && canal_courant.prog1.debut.QuadPart != 0) { - - HWND msnui = FindWindow(L"MsnMsgrUIManager", NULL); if (msnui != NULL) @@ -1168,18 +1060,9 @@ } } - //tip systray - if(minimize_system_tray && first_pass) { - //niData.hWnd = hMainWnd; - wchar_t tip[128]; - swprintf_s(tip, _countof(tip), L"%S - %S", canal_courant.nom, canal_courant.prog1.nom); - lstrcpy(niData.szTip, tip); - Shell_NotifyIcon(NIM_MODIFY,&niData); - } - first_pass = true; + niData.update_tip(); } - static void switch_audio(int old_son, int new_son) { const un_son * son_courant = Canaux[chaineCourante].son; @@ -1202,7 +1085,7 @@ } sonCourant=new_son; - update_pistes_menu(hMainWnd); + update_menus(hMainWnd, 1, update_pistes_menu); } void zappe_index(int nouvelle_chaine) @@ -1309,7 +1192,7 @@ } } -static void zappe_chaine(int nouvelle_chaine) +void zappe_chaine(int nouvelle_chaine) { // cherche l'index de la chaîne voulue int trouve = -1; @@ -1535,307 +1418,6 @@ return 0; } -static INT_PTR CALLBACK ConfigDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - - switch (uMsg) { - - case WM_INITDIALOG: - - remplit_tuners(KSCATEGORY_BDA_NETWORK_TUNER, hwndDlg, IDC_COMBO_TUNER); - SendDlgItemMessage(hwndDlg, IDC_COMBO_TUNER, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)nom_tuner); - - remplit_tuners(KSCATEGORY_BDA_RECEIVER_COMPONENT, hwndDlg, IDC_COMBO_RECEIVER); - SendDlgItemMessage(hwndDlg, IDC_COMBO_RECEIVER, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)nom_receiver); - - search_filters(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO, hwndDlg, IDC_COMBO_MPEG2); - SendDlgItemMessage(hwndDlg, IDC_COMBO_MPEG2, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)filtreMPEG2); - - search_filters(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO, hwndDlg, IDC_COMBO_AUDIO); - SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)filtreAudio); - - search_filters(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3, hwndDlg, IDC_COMBO_AC3); - SendDlgItemMessage(hwndDlg, IDC_COMBO_AC3, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)filtreAc3); - - - return TRUE; - - case WM_COMMAND: - - LRESULT res; - - switch(LOWORD(wParam)) { - - case IDOK: - // sauvegarder le changement - - res = SendDlgItemMessage(hwndDlg, IDC_COMBO_TUNER, CB_GETCURSEL, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_COMBO_TUNER, CB_GETLBTEXT, res, (LPARAM)nom_tuner); - - res = SendDlgItemMessage(hwndDlg, IDC_COMBO_RECEIVER, CB_GETCURSEL, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_COMBO_RECEIVER, CB_GETLBTEXT, res, (LPARAM)nom_receiver); - - res = SendDlgItemMessage(hwndDlg, IDC_COMBO_MPEG2, CB_GETCURSEL, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_COMBO_MPEG2, CB_GETLBTEXT, res, (LPARAM)filtreMPEG2); - - res = SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO, CB_GETCURSEL, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO, CB_GETLBTEXT, res, (LPARAM)filtreAudio); - - res = SendDlgItemMessage(hwndDlg, IDC_COMBO_AC3, CB_GETCURSEL, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_COMBO_AC3, CB_GETLBTEXT, res, (LPARAM)filtreAc3); - - myprintf(L"Video : %s\nAudio : %s\nAc3 : %s\n", filtreMPEG2, filtreAudio, filtreAc3); - - save_config(); - - case IDCANCEL: - - EndDialog(hwndDlg, LOWORD(wParam)); - return TRUE; - } - return FALSE; - - default: - return FALSE; - } -} - -static LRESULT AddLineToList(HWND hListItem, LPCWSTR str) { - return - SendMessage(hListItem, LB_SETTOPINDEX, - (WPARAM)SendMessage(hListItem, LB_ADDSTRING, 0, (LPARAM)str), - 0); -} - -static LRESULT RecupereNomVille(HWND hComboItem) { - return - SendMessage(hComboItem, CB_GETLBTEXT, - SendMessage(hComboItem, CB_GETCURSEL, 0, 0), - (LPARAM)nomVille); -} - -static void restaure_chaine(WORD numero) -{ - trie_chaines(); // trie les chaînes par numéro - // - if (numero>0) { - // On essaye de remettre la même chaîne qu'avant, s'il y en avait une : - zappe_chaine(numero); - } else if (!Canaux.empty()) { - // S'il n'y en avait pas, on met la première de la liste ... - // ... laquelle a toutes les chances d'être TF1, mais bon ... :-( - zappe_index(0); - } -} - -static INT_PTR CALLBACK ScanProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static INT a_tabs[5] = {24, 79, 130, 146, 245}; // Positions des tabulations dans la list box - static enum { - ss_idle, - ss_cancelling, - ss_stopping, - ss_running - } scanState = ss_idle; - static bool stopping = false; - static bool tuning = false; - static WORD numeroChaine = 0; - static HWND hComboItem = NULL; - static HWND hListItem = NULL; - static HWND hStartBut = NULL; - static HWND hCancelBut = NULL; - static HWND hOkBut = NULL; - static HWND hInfoText = NULL; - static HWND hProgBar = NULL; - static int cancelCode = 1; - static int index; - // - switch (uMsg) { - - case WM_INITDIALOG: - // Obtenir les handles de certains items : - hComboItem = GetDlgItem(hwndDlg, IDC_COMBO_VILLE); // Combo des villes - hListItem = GetDlgItem(hwndDlg, IDC_CHANNEL_LIST); // List box - hStartBut = GetDlgItem(hwndDlg, IDC_START); // Bouton "Lancer" - hCancelBut = GetDlgItem(hwndDlg, IDCANCEL); // Bouton "Annuler" - hOkBut = GetDlgItem(hwndDlg, IDOK); // Bouton "Accepter" - hInfoText = GetDlgItem(hwndDlg, IDC_SCAN_INFO); // Champ d'informations - hProgBar = GetDlgItem(hwndDlg, IDC_SCAN_PROGRESS); // Barre de progression - // - cancelCode = 1; - numeroChaine = chaineCourante>=0 ? Canaux[chaineCourante].numero_nit : 0; - remplit_combo_ville(hComboItem); - SendMessage(hComboItem, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)nomVille); - // - // Définir les tabulations dans la list box : - SendMessage(hListItem, LB_SETTABSTOPS, (WPARAM)_countof(a_tabs), (LPARAM)a_tabs); - AddLineToList(hListItem, L"Cliquez sur « Démarrer » pour commencer la recherche"); - //i = (size_t)-1; - scanState = ss_idle; - return TRUE; - - case WM_COMMAND: - switch (wParam) { - case MAKELONG(IDC_START, BN_CLICKED): - switch (scanState) { - case ss_idle: - zappe_index(-1); - Canaux.clear(); - chaineIDs.clear(); - nit_chargee = false; // On a besoin de relire la NIT - - SendMessage(hListItem, LB_RESETCONTENT, 0, 0); // Vider la liste - EnableWindow(hOkBut, FALSE); // Désactiver le bouton "Accepter" - EnableWindow(hComboItem, FALSE); // Désactiver la liste des villes - PostMessage(hwndDlg, WM_APP, 0, 0); - SetWindowText(hStartBut, L"Arrêter"); - scanState = ss_running; - stopping = false; - cancelCode = -1; - index = 0; - Sleep(50); // Laisser tout ça se rafraîchir à l'affichage - break; - case ss_running: - EnableWindow(hStartBut, FALSE); - AddLineToList(hListItem, L"Arrêt en cours"); - scanState = ss_stopping; - stopping = true; - } - break; - case MAKELONG(IDCANCEL, BN_CLICKED): - EnableWindow(hCancelBut, FALSE); - EnableWindow(hStartBut, FALSE); - if (tuning) { - // On est en récursion à l'intérieur de "tune" - AddLineToList(hListItem, L"Annulation en cours"); - stopping = true; - scanState = ss_cancelling; - return FALSE; - } - if (cancelCode==-1) { - zappe_index(-1); - Canaux.clear(); - chaineCourante = -1; - // Si la recherche est annulée par l'utilisateur, alors on recharge - // le fichier de chaînes précédent : - lit_chaines(); - restaure_chaine(numeroChaine); - } - EndDialog(hwndDlg, cancelCode); // 1 = annulé sans scan, -1 = annulé après tentative de scan - return TRUE; - case MAKELONG(IDOK, BN_CLICKED): - RecupereNomVille(hComboItem); - sauve_chaines(); // sauvegarde les chaînes dans le ini - save_config(); // sauvegarde la configuration (le nom de ville peut avoir changé) - EndDialog(hwndDlg, 0); // 0 = pas d'erreur - return TRUE; - case MAKELONG(IDC_COMBO_VILLE, CBN_SELCHANGE): - RecupereNomVille(hComboItem); - return TRUE; - } - return FALSE; - - case WM_APP: // Recherche pour une fréquence (index dans wParam) - // (on n'utilise pas WM_USER, parce que apparemment, - // certains objets du dialogue s'en servent !!) - if (!tuning) { // (prévention réentrance) - if (wParam==0) { - // Initialisation recherche - lit_fichier_scan(nomVille); - - // L'intervalle de progression comporte trois étapes de plus qu'il y a de fréquences, - // car, d'une part la lecture de la NIT constitue une étape à part et compte pour deux - // en raison de sa durée, et d'autre part le simple démarrage constitue une étape - // (plus rassurant pour l'utilisateur). - SendMessage(hProgBar, PBM_SETRANGE, 0, MAKELPARAM(0, freq_scan.size()+3)); - SendMessage(hProgBar, PBM_SETPOS, 1, 0); - } - const Frequence & freq = freq_scan[wParam]; - wchar_t szFreq[16]; - wchar_t szTemp[128]; - unsigned last_num = Canaux.size(); - - swprintf_s(szFreq, _countof(szFreq), L"%03u,%03u MHz", freq.mhz/1000, freq.mhz%1000); - swprintf_s(szTemp, _countof(szTemp), L"Examen canal %u à %s", freq.canal_no, szFreq); - SetWindowText(hInfoText, szTemp); - tuning = true; - tune(hwndDlg, freq, &stopping); - - if (!stopping) { - // Affichage des canaux qui viennent d'être ajoutés : - for (; last_num < Canaux.size(); last_num++) { - const Chaine & canal = Canaux[last_num]; - - if (canal.nom[0]) { - char norme = - canal.video_pid!=0 ? - (canal.mpeg4_pid!=0 ? 'X': '2') : - (canal.mpeg4_pid!=0 ? '4': '?'); - - swprintf_s(szTemp, _countof(szTemp), L"%u\t%s\t%S\t%u\t%S\t%c", canal.canal_no, szFreq, - *canal.groupe ? canal.groupe : "", canal.numero_nit, canal.nom, norme); - AddLineToList(hListItem, szTemp); - } - } - index = (int)wParam; - SendMessage(hProgBar, PBM_SETPOS, index+(nit_chargee ? 4 : 2), 0); - } - - tuning = stopping = false; - SetWindowText(hInfoText, L""); - - switch (scanState) { - case ss_cancelling: - // Annulation demandée : - PostMessage(hwndDlg, WM_COMMAND, MAKELONG(IDCANCEL, BN_CLICKED), NULL); - break; - case ss_stopping: - EnableWindow(hStartBut, TRUE); - EnableWindow(hComboItem, TRUE); // Réactiver la liste des villes - AddLineToList(hListItem, L"Interrompu"); - SetWindowText(hStartBut, L"Recommencer"); - scanState = ss_idle; - break; - case ss_running: - if (wParam+1 < freq_scan.size()) { - // Demander la recherche pour la fréquence suivante : - PostMessage(hwndDlg, WM_APP, wParam+1, 0); - } else { - // Recherche terminée : - chaineIDs.clear(); // Vide la table des numéros de chaînes, dont on n'aura plus besoin - SetWindowText(hStartBut, L"Recommencer"); - scanState = ss_idle; - EnableWindow(hComboItem, TRUE); // Réactiver la liste des villes - EnableWindow(hOkBut, TRUE); - AddLineToList(hListItem, L"Recherche des fréquences terminée"); - if (Canaux.empty()) { - static LPCWSTR msg_aucune = L"Aucune chaîne n'a été trouvée"; - - erreur(msg_aucune); - AddLineToList(hListItem, msg_aucune); - } else { - do_init_vmr(); - restaure_chaine(numeroChaine); - } - // - // S'assurer que la barre de progression indique toujours ici le maximum, même si aucune - // chaîne n'a été trouvée : - SendMessage(hProgBar, PBM_SETPOS, freq_scan.size()+3, 0); - } - } - - return TRUE; - } - break; - case WM_APP+1: - // Traitement du message d'information envoyé par la fonction "tune" - // au début de l'analyse de la NIT : - SendMessage(hProgBar, PBM_SETPOS, index+(nit_chargee ? 4 : 2), 0); - SetWindowText(hInfoText, L"Lecture des numéros des chaînes"); - } - - return FALSE; -} - /** * On passe un numéro de chaine en paramètre, * et on retourne la fréquence du multiplex correspondant @@ -2196,34 +1778,6 @@ } } -static int scanne(void) -{ - int res = (int)DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_SCAN), hMainWnd, ScanProc); - if (res!=0) - return res; - - if (Canaux.empty()) - return 1; - - return 0; -} - -// Obtenir l'état courant de la fenêtre (à partir de la valeur déjà obtenue par GetWindowLongPtr) : -inline EtatsFenetre etat_fenetre(LONG_PTR ws) -{ - return - ws & WS_MINIMIZE ? etf_minimized : - ws & WS_MAXIMIZE ? - (ws & WS_CAPTION ? etf_maximized : etf_fullscreen) : - (ws & WS_CAPTION ? etf_normal : etf_noborders); -} - -// Obtenir l'état courant de la fenêtre (à partir de la handle de la celle-ci) : -EtatsFenetre etat_fenetre(HWND hWnd) -{ - return etat_fenetre(GetWindowLongPtr(hWnd, GWL_STYLE)); -} - void switch_etat_fenetre(EtatsFenetre nouvel_etat); // forward static void switch_on_top(void) @@ -2234,18 +1788,7 @@ on_top = !on_top; switch_etat_fenetre(etat_fenetre(hMainWnd)); - - HMENU hMenu = GetMenu(hMainWnd); - - if (hMenu != NULL) { - MENUITEMINFO info; - info.cbSize = sizeof(MENUITEMINFO); - info.fMask = MIIM_STATE; - info.fState = on_top ? MFS_CHECKED : MFS_UNCHECKED; - - SetMenuItemInfo(hMenu, IDM_ALWAYS_ON_TOP, FALSE, &info); - - } + update_menus(hMainWnd, 1, update_ontop_menu); } @@ -2258,24 +1801,21 @@ pBas->Release(); } -static int InitDshow(void) +static int InitDshow(void) // retourne 0 = pas d'erreur, 1 = erreur { int result = build_graph(); if (result != 0) return result; if (Canaux.size()==0) { - result = scanne(); - if (result != 0) - return result; + if (scan_dialog()!=IDOK) + return 1; } if (Canaux.size() == 0) { erreur(L"Aucune chaîne n'est dans le fichier"); } - init_list_lang(); - // restaure l'option on top //on_top = !on_top; // supprimé car implicite dans la nouvelle @@ -2420,17 +1960,17 @@ // Commande reçue (clic, etc...) switch(LOWORD(wParam)) { - case IDOK: - // Clic sur le bouton OK - stop_all_records(); - update_menu_recording(hMainWnd); - EndDialog(hwndDlg, 1); - return TRUE; + case IDOK: + // Clic sur le bouton OK + stop_all_records(); + update_record_menus(hMainWnd); + EndDialog(hwndDlg, 1); + return TRUE; - case IDCANCEL: - // Clic sur le bouton Annuler - EndDialog(hwndDlg, 0); - return TRUE; + case IDCANCEL: + // Clic sur le bouton Annuler + EndDialog(hwndDlg, 0); + return TRUE; } // Autre commandes, traitées par Windows return FALSE; @@ -2630,9 +2170,7 @@ update_status_size(); if (chaineCourante >=0 && chaineCourante < (int)Canaux.size()) - { update_status_bar(); - } } static bool remove_borders() @@ -2748,6 +2286,7 @@ wpl.showCmd = newShowCmd; SetWindowPlacement(hMainWnd, &wpl); //ShowWindow(hMainWnd, newShowCmd); // provoque une animation de fenêtre gênante + update_menus(hMainWnd, 1, update_fullscreen_menu); } if (change) { @@ -2775,6 +2314,7 @@ if (!is_vista) { RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } + update_menus(hMainWnd, 1, update_mute_menu); } static void update_volume(bool augmente) @@ -2906,16 +2446,6 @@ } } -/** - * Fonction sélectionnant le répertoire initial lors de la demande d'un dossier - **/ -static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) -{ - if(uMsg == BFFM_INITIALIZED) - SendMessage(hWnd, BFFM_SETSELECTION, 1, lpData); - return 0; -} - // Arrêt de l'ordinateur : static bool shutdown() { @@ -3177,8 +2707,7 @@ // On mémorise ce qu'il faut faire à la fin de l'enregistrement programmé enregistrements_actuels[grab].apres = prog.after; - update_menu_recording(hMainWnd); - update_chaines_menu(hMainWnd); + update_record_menus(hMainWnd); // Vérif si l'heure de début est déjà passée SYSTEMTIME localtime; @@ -3508,8 +3037,7 @@ enregistrements_actuels[grab].apres = apr_rien; pSample[grab]->SetCallback(pCallback, 0); - update_menu_recording(hMainWnd); - update_chaines_menu(hMainWnd); + update_record_menus(hMainWnd); } } @@ -3532,8 +3060,7 @@ enregistrements_actuels[grab].apres = apr_rien; pSample[grab]->SetCallback(pCallback, 0); - update_menu_recording(hMainWnd); - update_chaines_menu(hMainWnd); + update_record_menus(hMainWnd); } } @@ -3555,34 +3082,6 @@ } #endif // #if USE_RECORD_STREAM -static void do_select_dir(LPWSTR dir, LPCWSTR title) -{ - BROWSEINFO bi; - memset(&bi, 0, sizeof(BROWSEINFO)); - - wchar_t display_name[MAX_PATH]; - - bi.hwndOwner = hMainWnd; // Handle de la fenêtre - bi.pszDisplayName = display_name; // Variable recevant le dossier sélectionné - bi.lpszTitle = title; // Message à afficher dans la fenêtre - bi.ulFlags = BIF_RETURNONLYFSDIRS; // N'afiche que les dossiers - bi.lpfn = BrowseCallbackProc; // Adresse de la fonction de CallBack - bi.lParam = (LPARAM)dir; // Paramètre passé à la fonction de CallBack - bi.pidlRoot = NULL; // À partir de quel dossier faut-il rechercher ? - - ShowCursor(TRUE); - - LPITEMIDLIST iil = SHBrowseForFolder(&bi); - - ShowCursor(FALSE); - - if (iil != NULL) { - SHGetPathFromIDList(iil, dir); - CoTaskMemFree(iil); - save_config(); - } -} - static void do_command(WORD wID) { int grab; @@ -3600,16 +3099,16 @@ break; case IDM_CONFIG: - DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_CONFIG), hMainWnd, ConfigDialogProc); + do_config(hMainWnd); break; case IDM_CHANNELS: { static bool rechercheEncours = false; if (!rechercheEncours) { rechercheEncours = true; - int res = scanne(); - update_chaines_menu(hMainWnd); // ajoute les chaînes dans le menu - if (res==-1) + BYTE res = scan_dialog(); + update_menus(hMainWnd, 1, update_chaines_menu); // ajoute les chaînes dans le menu + if (res==IDABORT) MessageBox(hMainWnd, L"Annulation : La configuration précédente des chaînes a été rétablie", L"Recherche annulée", MB_ICONINFORMATION | MB_OK); @@ -3662,7 +3161,9 @@ case IDM_ZOOM: zoom_ratio++; - if (zoom_ratio > 200) zoom_ratio = 200; + if (zoom_ratio > 200) + zoom_ratio = 200; + update_menus(hMainWnd, 1, update_aspect_menus); update_coords(); last_zoom = GetTickCount(); set_timer_osd(); @@ -3670,7 +3171,9 @@ case IDM_DEZOOM: zoom_ratio--; - if (zoom_ratio <= 0) zoom_ratio = 1; + if (zoom_ratio <= 0) + zoom_ratio = 1; + update_menus(hMainWnd, 1, update_aspect_menus); update_coords(); last_zoom = GetTickCount(); if (is_vista) { @@ -3682,7 +3185,7 @@ case IDM_DEFAULT_ZOOM: zoom_ratio = 100; use_all_width = false; - update_all_width_and_ar_menu(hMainWnd); + update_menus(hMainWnd, 1, update_aspect_menus); update_coords(); last_zoom = GetTickCount(); set_timer_osd(); @@ -3690,16 +3193,18 @@ case IDM_STRETCH: use_all_width = !use_all_width; - if (etirer_video && use_all_width) etirer_video = false; - update_all_width_and_ar_menu(hMainWnd); + if (etirer_video && use_all_width) + etirer_video = false; + update_menus(hMainWnd, 1, update_aspect_menus); update_coords(); RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); break; case IDM_NOAR: etirer_video = !etirer_video; - if (etirer_video && use_all_width) use_all_width = false; - update_all_width_and_ar_menu(hMainWnd); + if (etirer_video && use_all_width) + use_all_width = false; + update_menus(hMainWnd, 1, update_aspect_menus); update_coords(); RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); break; @@ -3753,16 +3258,6 @@ } break; - case IDM_MPEG2_DIR: - do_select_dir(video_dir, - L"Choisissez le répertoire où seront enregistrées les vidéos :"); - break; - - case IDM_SCREENSHOTS_DIR: - do_select_dir(screenshots_dir, - L"Choisissez le répertoire où seront enregistrées les captures d'écran :"); - break; - case IDM_EPG: if (hEpgDlg) BringWindowToTop(hEpgDlg); @@ -3785,56 +3280,6 @@ switch_on_top(); break; - case IDM_MSN: - use_msn = !use_msn; - if (use_msn) - { - update_status_bar(); - } else { - HWND msnui = FindWindow(L"MsnMsgrUIManager", NULL); - - if (msnui != NULL) - { - COPYDATASTRUCT msndata; - msndata.dwData = 0x547; - msndata.lpData = L"\\0Music\\00\\0\\0\\0\\0\\0\\0"; - msndata.cbData = (lstrlenW((wchar_t *) msndata.lpData)*2)+2; - SendMessage(msnui, WM_COPYDATA, (WPARAM)hMainWnd, (LPARAM)&msndata); - } - } - update_msn_menu(hMainWnd); - break; - - case IDM_AC3_DEF: - use_ac3 = !use_ac3; - update_ac3_menu(hMainWnd); - break; - - case IDM_SUSPEND: - suspend_minimized = !suspend_minimized; - update_suspend_menu(hMainWnd); - break; - - case IDM_SYSTEM_TRAY: - minimize_system_tray = !minimize_system_tray; - update_system_tray_menu(hMainWnd); - // sert plus a rien ? - //ShowWindow(hMainWnd, SW_HIDE); - if (minimize_system_tray) { - SetWindowLongPtr(hMainWnd, GWL_EXSTYLE, 0); - niData.hWnd = hMainWnd; - wchar_t tip[128]; - const Chaine & canal_courant = Canaux[chaineCourante]; - swprintf_s(tip, _countof(tip), L"%S - %S", canal_courant.nom, canal_courant.prog1.nom); - lstrcpy(niData.szTip, tip); - Shell_NotifyIcon(NIM_ADD,&niData); - } else { - SetWindowLongPtr(hMainWnd, GWL_EXSTYLE, WS_EX_APPWINDOW); - Shell_NotifyIcon(NIM_DELETE,&niData); - } - //ShowWindow(hMainWnd, SW_SHOW); - break; - case IDM_VOL_AUG: update_volume(true); if (is_vista) { @@ -3885,11 +3330,11 @@ SetTimer(hMainWnd, TIMER_UPDATE, USER_TIMER_MINIMUM, NULL); break; - case SC_MINIMIZE: + case IDM_MINIMIZE: SendMessage(hMainWnd, WM_SYSCOMMAND, SC_MINIMIZE, NULL); break; - case SC_RESTORE: + case IDM_RESTORE: SendMessage(hMainWnd, WM_SYSCOMMAND, SC_RESTORE, NULL); break; @@ -3941,6 +3386,8 @@ case etf_fullscreen: switch_etat_fenetre(etf_maximized); } + // Le statut "plein écran" peut avoir changé au passage : + update_menus(hMainWnd, 1, update_fullscreen_menu); break; case TIMER_OSD: @@ -4054,43 +3501,44 @@ set_priority(IDLE_PRIORITY_CLASS); clean_dshow(); - Shell_NotifyIcon(NIM_DELETE,&niData); + niData.disable(); PostQuitMessage(0); break; case WM_MENUSELECT: // Au cas où une application externe aurait changé la priorité : if (get_priority()!=configPriority) - update_priority_menu(hWnd); + update_menus(hWnd, 1, update_priority_menu); lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); break; case MY_TRAY_ICON_MESSAGE: - switch(lParam) { - case WM_LBUTTONDBLCLK: - if (IsMinimized(hWnd)) { - if (!do_init_vmr()) - return -1; - if (suspend_minimized) { - rebranche(); + if (wParam==MY_TRAY_ICON_ID) { + switch(lParam) { + case WM_LBUTTONDBLCLK: + if (IsMinimized(hWnd)) { + if (!do_init_vmr()) + return -1; + if (suspend_minimized) { + rebranche(); change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire zappe_index(chaineCourante); + } + ShowWindow(hWnd, SW_SHOW); + ShowWindow(hWnd, SW_RESTORE); + } else { + SetForegroundWindow(hWnd); } - ShowWindow(hWnd, SW_SHOW); - ShowWindow(hWnd, SW_RESTORE); - } else { - SetForegroundWindow(hWnd); - } - break; - case WM_LBUTTONDOWN: - if (!IsMinimized(hWnd)) - SetForegroundWindow(hWnd); - break; - case WM_CONTEXTMENU: - case WM_RBUTTONDOWN: - popup_menu(true); - break; + break; + case WM_LBUTTONDOWN: + if (!IsMinimized(hWnd)) + SetForegroundWindow(hWnd); + break; + case WM_CONTEXTMENU: + case WM_RBUTTONUP: + popup_menu(true); + } } break; @@ -4354,6 +3802,10 @@ // on lit la config maintenant, besoin des coords de la fenetre load_config(); + // Chargement des icônes du programme : + hPrgIcon = LoadIcon(hAppInstance, MAKEINTRESOURCE(IDI_PROG_ICON)); // Icône normale + hRecIcon = LoadIcon(hAppInstance, MAKEINTRESOURCE(IDI_ICON_REC)); // Icône d'enregistrement + INITCOMMONCONTROLSEX icc={sizeof(INITCOMMONCONTROLSEX), ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_DATE_CLASSES}; InitCommonControlsEx(&icc); @@ -4369,15 +3821,6 @@ wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MAIN_MENU); wndclass.lpszClassName = szAppName; - ZeroMemory(&niData,sizeof(NOTIFYICONDATA)); - - niData.cbSize = sizeof(NOTIFYICONDATA); - - niData.uID = MY_TRAY_ICON_ID; - niData.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP; - niData.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_PROG_ICON)); - niData.uCallbackMessage = MY_TRAY_ICON_MESSAGE; - if (!RegisterClass(&wndclass)) return 0; #if USE_CONSOLE==1 startConsoleWin(); @@ -4416,9 +3859,7 @@ CSIDL_MYPICTURES /* = Répertoire "Mes images" */, "captures d'écrans"); // Si on minimise dans la zone système, n'affiche pas la fenêtre dans la barre des tâches - if (!minimize_system_tray) { - SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW); - } + update_systray_state(); // Comme marqué, on crée la barre de status de la fenêtre create_status_bar(); @@ -4493,7 +3934,7 @@ do { if (!config_ok) { - if (DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_CONFIG), hWnd, ConfigDialogProc)!=IDOK) { + if (drivers_dialog()!=IDOK) { erreur(L"Configuration annulée.\nLe logiciel ne peut pas être exécuté."); return -1; } @@ -4518,15 +3959,24 @@ } else { if (!do_init_vmr()) return -1; - /* Force le changement de fréquence, sans quoi on a un écran noir au démarrage avec - le tuner USB Toshiba PX1256E-1TVH */ - for (int i=0; i<(int)Canaux.size(); i++) { - if (Canaux[i].frequence != Canaux[chaineCourante].frequence) { - change_frequence(Canaux[i].frequence); - break; + + int nbr_chaines = Canaux.size(); + + if (chaineCourante>=0 && chaineCouranteRelease(); @@ -269,7 +269,7 @@ return res; } -int remplit_tuners(GUID guid, HWND hDlg, int item) +int remplit_tuners(GUID guid, HWND hItm) { // Create the System Device Enumerator. ICreateDevEnum * pDevEnum; @@ -307,7 +307,7 @@ VariantInit(&varName); if (SUCCEEDED(pPropBag->Read(L"FriendlyName", &varName, 0))) { - SendDlgItemMessage(hDlg, item, CB_ADDSTRING, 0, (LPARAM)varName.bstrVal); + SendMessage(hItm, CB_ADDSTRING, 0, (LPARAM)varName.bstrVal); } VariantClear(&varName); pPropBag->Release(); Modified: trunk/search.h =================================================================== --- trunk/search.h 2007-10-11 21:12:45 UTC (rev 90) +++ trunk/search.h 2007-10-12 08:26:20 UTC (rev 91) @@ -2,10 +2,10 @@ //IBaseFilter * search_mpeg2(IEnumMoniker *pEnumMoniker, GUID subtype, GUID format); IPin * cherche_pin(IBaseFilter * pFilter, PIN_DIRECTION dir); -void search_filters(GUID type, GUID subtype, HWND hDlg, int item); +void search_filters(GUID type, GUID subtype, HWND hItm); IBaseFilter * get_filter(GUID type, GUID subtype, wchar_t * nom); -int remplit_tuners(GUID guid, HWND hDlg, int item); +int remplit_tuners(GUID guid, HWND hItm); IBaseFilter * get_tuner(GUID guid, wchar_t * nom); int filtre_compat(IBaseFilter * pFilter); From pouchintv-svn at baysse.fr Fri Oct 12 10:32:18 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Fri, 12 Oct 2007 10:32:18 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r92 - trunk Message-ID: <20071012083219.159BD5F2E4@mail.baysse.fr> Author: gingko Date: 2007-10-12 10:32:18 +0200 (Fri, 12 Oct 2007) New Revision: 92 Added: trunk/settings.cpp trunk/settings.h trunk/trayicon.cpp trunk/trayicon.h Log: Heu d?\195?\169sol?\195?\169 ... Je n'avais pas ajout?\195?\169 les quatre fichiers suppl?\195?\169mentaires ... Added: trunk/settings.cpp =================================================================== --- trunk/settings.cpp (rev 0) +++ trunk/settings.cpp 2007-10-12 08:32:18 UTC (rev 92) @@ -0,0 +1,621 @@ +/* + * settings.cpp + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#include "base.h" +#include "main.h" +#include "ini.h" +#include "parse.h" +#include "search.h" +#include "trayicon.h" + +#include + +#define _cmd_ MAKELONG // -> pour tenter de rendre les choses plus lisibles + +// Passé via lParam aux fonction "callback" des dialogues pour leur permettre de différencier +// entre le mode "property sheet" et le mode dialogue normal (ceci permet d'utiliser, dans +// certains cas, le même modèle de boîte de dialogue dans une feuille de propriétés ou bien +// dans un dialogue autonome). +#define DIALOGMODE ((LPARAM)FALSE) +#define PROPSHEETMODE ((LPARAM)TRUE) + +// Assistance au retour de valeur après notification dans une feuille de propriétés : +BOOL psn_result(HWND hDlg, LONG res) +{ + SetWindowLongPtr(hDlg, DWL_MSGRESULT, res); + return TRUE; +} + +static LRESULT remplit_combo_tuner(HWND hItm, GUID guid, LPCWSTR nom) +{ + remplit_tuners(guid, hItm); + return SendMessage(hItm, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)nom); +} + +static LRESULT remplit_combo_filtre(HWND hItm, GUID type, GUID subtype, LPCWSTR nom) +{ + search_filters(type, subtype, hItm); + return SendMessage(hItm, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)nom); +} + +static LRESULT remplit_combo_ville(HWND hItm, LPCWSTR nom) +{ + remplit_villes(hItm); + return SendMessage(hItm, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)nom); +} + +static bool extrait_combo(HWND hItm, LPWSTR nom, size_t size) +{ + wchar_t temp[256]; + + SendMessage(hItm, CB_GETLBTEXT, + SendMessage(hItm, CB_GETCURSEL, 0, 0), + (LPARAM)temp); + + if (wcscmp(nom, temp)==0) + return false; // false = Aucun changement + wcscpy_s(nom, size, temp); + return true; // true = Changement +} + +bool drivers_apply(HWND hDlg) +{ + bool changed = false; + + changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_TUNER), nom_tuner, _countof(nom_tuner)); + changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_RECEIVER), nom_receiver, _countof(nom_receiver)); + changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_MPEG2), filtreMPEG2, _countof(filtreMPEG2)); + changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_AUDIO), filtreAudio, _countof(filtreAudio)); + changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_AC3), filtreAc3, _countof(filtreAc3)); + myprintf(L"Video : %s\nAudio : %s\nAc3 : %s\n", filtreMPEG2, filtreAudio, filtreAc3); + return changed; +} + +static INT_PTR CALLBACK DriversDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { + + switch (uMsg) { + + case WM_INITDIALOG: + if (lParam!=0) { + // Si on est dans une feuille de propriétés, on enlève certains items : + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_HIDE); + ShowWindow(GetDlgItem(hDlg, IDOK), SW_HIDE); + } + remplit_combo_tuner(GetDlgItem(hDlg, IDC_COMBO_TUNER), + KSCATEGORY_BDA_NETWORK_TUNER, nom_tuner); + remplit_combo_tuner(GetDlgItem(hDlg, IDC_COMBO_RECEIVER), + KSCATEGORY_BDA_RECEIVER_COMPONENT, nom_receiver); + remplit_combo_filtre(GetDlgItem(hDlg, IDC_COMBO_MPEG2), + MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO, filtreMPEG2); + remplit_combo_filtre(GetDlgItem(hDlg, IDC_COMBO_AUDIO), + MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO, filtreAudio); + remplit_combo_filtre(GetDlgItem(hDlg, IDC_COMBO_AC3), + MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3, filtreAc3); + return TRUE; + + case WM_COMMAND: + + switch(wParam) { + case _cmd_(IDC_COMBO_TUNER, LBN_SELCHANGE): + case _cmd_(IDC_COMBO_RECEIVER, LBN_SELCHANGE): + case _cmd_(IDC_COMBO_MPEG2, LBN_SELCHANGE): + case _cmd_(IDC_COMBO_AUDIO, LBN_SELCHANGE): + case _cmd_(IDC_COMBO_AC3, LBN_SELCHANGE): + PropSheet_Changed(GetParent(hDlg), hDlg); + break; + case _cmd_(IDOK, BN_CLICKED): + // sauvegarder le changement + drivers_apply(hDlg); + // ... passage à travers + case _cmd_(IDCANCEL, BN_CLICKED): + + EndDialog(hDlg, LOWORD(wParam)); + return TRUE; + } + return FALSE; + + case WM_NOTIFY: + switch (((NMHDR FAR *) lParam)->code) { + case PSN_APPLY: // Application des changements + if (drivers_apply(hDlg)) { + MessageBox(hMainWnd, + L"Les modifications apportées à la configuration matérielle ou bien\n" + L"aux codecs utilisés s'appliqueront après redémarrage de l'application.", + L"Paramètres modifiés", MB_ICONINFORMATION); + } + return psn_result(hDlg, PSNRET_NOERROR); + } + return FALSE; + + default: + return FALSE; + } +} + +static LRESULT AddLineToList(HWND hListItem, LPCWSTR str) { + return + SendMessage(hListItem, LB_SETTOPINDEX, + (WPARAM)SendMessage(hListItem, LB_ADDSTRING, 0, (LPARAM)str), + 0); +} + +static void restaure_chaine(WORD numero) +{ + trie_chaines(); // trie les chaînes par numéro + // + if (numero>0) { + // On essaye de remettre la même chaîne qu'avant, s'il y en avait une : + zappe_chaine(numero); + } else if (!Canaux.empty()) { + // S'il n'y en avait pas, on met la première de la liste ... + // ... laquelle a toutes les chances d'être TF1, mais bon ... :-( + zappe_index(0); + } +} + +enum ScanState +{ + ss_idle, + ss_cancelling, + ss_stopping, + ss_running +}; + +static INT_PTR CALLBACK ScanDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static INT a_tabs[5] = {24, 79, 130, 146, 245}; // Positions des tabulations dans la list box + static enum { + ss_idle, + ss_cancelling, + ss_stopping, + ss_running + } scanState = ss_idle; + static bool stopping = false; + static bool tuning = false; + static WORD numeroChaine = 0; + static HWND hComboItem = NULL; + static HWND hListItem = NULL; + static HWND hStartBut = NULL; + static HWND hCancelBut = NULL; + static HWND hOkBut = NULL; + static HWND hInfoText = NULL; + static HWND hProgBar = NULL; + static int cancelCode = IDCANCEL; + static int index; + // + switch (uMsg) { + + case WM_INITDIALOG: + // Obtenir les handles de certains items : + hComboItem = GetDlgItem(hDlg, IDC_COMBO_VILLE); // Combo des villes + hListItem = GetDlgItem(hDlg, IDC_CHANNEL_LIST); // List box + hStartBut = GetDlgItem(hDlg, IDC_START); // Bouton "Lancer" + hCancelBut = GetDlgItem(hDlg, IDCANCEL); // Bouton "Annuler" + hOkBut = GetDlgItem(hDlg, IDOK); // Bouton "Accepter" + hInfoText = GetDlgItem(hDlg, IDC_SCAN_INFO); // Champ d'informations + hProgBar = GetDlgItem(hDlg, IDC_SCAN_PROGRESS); // Barre de progression + // + numeroChaine = chaineCourante>=0 ? Canaux[chaineCourante].numero_nit : 0; + remplit_combo_ville(hComboItem, nomVille); + SendMessage(hComboItem, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)nomVille); + // + // Définir les tabulations dans la list box : + SendMessage(hListItem, LB_SETTABSTOPS, (WPARAM)_countof(a_tabs), (LPARAM)a_tabs); + AddLineToList(hListItem, L"Cliquez sur « Démarrer » pour commencer la recherche"); + scanState = ss_idle; + return TRUE; + + case WM_COMMAND: + switch (wParam) { + case _cmd_(IDC_START, BN_CLICKED): + switch (scanState) { + case ss_idle: + if (nomVille[0]==0) { + erreur(L"Veuillez d'abord sélectionner une ville"); + break; + } + zappe_index(-1); + Canaux.clear(); + chaineIDs.clear(); + nit_chargee = false; // On a besoin de relire la NIT + + SendMessage(hListItem, LB_RESETCONTENT, 0, 0); // Vider la liste + EnableWindow(hOkBut, FALSE); // Désactiver le bouton "Accepter" + EnableWindow(hComboItem, FALSE); // Désactiver la liste des villes + PostMessage(hDlg, WM_APP, 0, 0); + SetWindowText(hStartBut, L"Arrêter"); + scanState = ss_running; + stopping = false; + cancelCode = IDABORT; + index = 0; + Sleep(50); // Laisser tout ça se rafraîchir à l'affichage + break; + case ss_running: + EnableWindow(hStartBut, FALSE); + AddLineToList(hListItem, L"Arrêt en cours"); + scanState = ss_stopping; + stopping = true; + } + break; + case _cmd_(IDCANCEL, BN_CLICKED): + EnableWindow(hCancelBut, FALSE); + EnableWindow(hStartBut, FALSE); + if (tuning) { + // On est en récursion à l'intérieur de "tune" + AddLineToList(hListItem, L"Annulation en cours"); + stopping = true; + scanState = ss_cancelling; + return FALSE; + } + if (cancelCode==IDABORT) { + zappe_index(-1); + Canaux.clear(); + chaineCourante = -1; + // Si la recherche est annulée par l'utilisateur, alors on recharge + // le fichier de chaînes précédent : + lit_chaines(); + restaure_chaine(numeroChaine); + } + EndDialog(hDlg, cancelCode); // IDCANCEL = annulé sans scan, + // IDABORT = annulé après tentative de scan + return TRUE; + case _cmd_(IDOK, BN_CLICKED): + extrait_combo(hComboItem, nomVille, _countof(nomVille)); + sauve_chaines(); // sauvegarde les chaînes dans le ini + EndDialog(hDlg, IDOK); // IDOK = pas d'erreur + return TRUE; + case _cmd_(IDC_COMBO_VILLE, CBN_SELCHANGE): + extrait_combo(hComboItem, nomVille, _countof(nomVille)); + return TRUE; + } + return FALSE; + + case WM_APP: // Recherche pour une fréquence (index dans wParam) + // (on n'utilise pas WM_USER, parce que apparemment, + // certains objets du dialogue s'en servent !!) + if (!tuning) { // (prévention réentrance) + if (wParam==0) { + // Initialisation recherche + lit_fichier_scan(nomVille); + + // L'intervalle de progression comporte trois étapes de plus qu'il y a de fréquences, + // car, d'une part la lecture de la NIT constitue une étape à part et compte pour deux + // en raison de sa durée, et d'autre part le simple démarrage constitue une étape + // (plus rassurant pour l'utilisateur). + SendMessage(hProgBar, PBM_SETRANGE, 0, MAKELPARAM(0, freq_scan.size()+3)); + SendMessage(hProgBar, PBM_SETPOS, 1, 0); + } + const Frequence & freq = freq_scan[wParam]; + wchar_t szFreq[16]; + wchar_t szTemp[128]; + unsigned last_num = Canaux.size(); + + swprintf_s(szFreq, _countof(szFreq), L"%03u,%03u MHz", freq.mhz/1000, freq.mhz%1000); + swprintf_s(szTemp, _countof(szTemp), L"Examen canal %u à %s", freq.canal_no, szFreq); + SetWindowText(hInfoText, szTemp); + tuning = true; + tune(hDlg, freq, &stopping); + + if (!stopping) { + // Affichage des canaux qui viennent d'être ajoutés : + for (; last_num < Canaux.size(); last_num++) { + const Chaine & canal = Canaux[last_num]; + + if (canal.nom[0]) { + char norme = + canal.video_pid!=0 ? + (canal.mpeg4_pid!=0 ? 'X': '2') : + (canal.mpeg4_pid!=0 ? '4': '?'); + + swprintf_s(szTemp, _countof(szTemp), L"%u\t%s\t%S\t%u\t%S\t%c", canal.canal_no, szFreq, + *canal.groupe ? canal.groupe : "", canal.numero_nit, canal.nom, norme); + AddLineToList(hListItem, szTemp); + } + } + index = (int)wParam; + SendMessage(hProgBar, PBM_SETPOS, index+(nit_chargee ? 4 : 2), 0); + } + + tuning = stopping = false; + SetWindowText(hInfoText, L""); + + switch (scanState) { + case ss_cancelling: + // Annulation demandée : + PostMessage(hDlg, WM_COMMAND, MAKELONG(IDCANCEL, BN_CLICKED), NULL); + break; + case ss_stopping: + EnableWindow(hStartBut, TRUE); + EnableWindow(hComboItem, TRUE); // Réactiver la liste des villes + AddLineToList(hListItem, L"Interrompu"); + SetWindowText(hStartBut, L"Recommencer"); + scanState = ss_idle; + break; + case ss_running: + if (wParam+1 < freq_scan.size()) { + // Demander la recherche pour la fréquence suivante : + PostMessage(hDlg, WM_APP, wParam+1, 0); + } else { + // Recherche terminée : + chaineIDs.clear(); // Vide la table des numéros de chaînes, dont on n'aura plus besoin + SetWindowText(hStartBut, L"Recommencer"); + scanState = ss_idle; + EnableWindow(hComboItem, TRUE); // Réactiver la liste des villes + EnableWindow(hOkBut, TRUE); + AddLineToList(hListItem, L"Recherche des fréquences terminée"); + if (Canaux.empty()) { + static LPCWSTR msg_aucune = L"Aucune chaîne n'a été trouvée"; + + erreur(msg_aucune); + AddLineToList(hListItem, msg_aucune); + } else { + do_init_vmr(); + restaure_chaine(numeroChaine); + } + // + // S'assurer que la barre de progression indique toujours ici le maximum, même si aucune + // chaîne n'a été trouvée : + SendMessage(hProgBar, PBM_SETPOS, freq_scan.size()+3, 0); + } + } + + return TRUE; + } + break; + case WM_APP+1: + // Traitement du message d'information envoyé par la fonction "tune" + // au début de l'analyse de la NIT : + SendMessage(hProgBar, PBM_SETPOS, index+(nit_chargee ? 4 : 2), 0); + SetWindowText(hInfoText, L"Lecture des numéros des chaînes"); + } + + return FALSE; +} + +LRESULT set_check(HWND hDlg, int nID, bool state) +{ + return SendDlgItemMessage(hDlg, nID, + BM_SETCHECK, state ? BST_CHECKED : BST_UNCHECKED, 0); +} + +bool get_check(HWND hDlg, int nID) +{ + return SendDlgItemMessage(hDlg, nID, BM_GETCHECK, 0, 0)==BST_CHECKED; +} + +static INT_PTR CALLBACK OptionsDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { + + switch (uMsg) { + + case WM_INITDIALOG: + set_check(hDlg, IDC_SUSPEND, suspend_minimized); + set_check(hDlg, IDC_SYSTEM_TRAY, minimize_system_tray); + set_check(hDlg, IDC_AC3_DEF, use_ac3); + set_check(hDlg, IDC_MSN, use_msn); + return TRUE; + + case WM_COMMAND: + switch(wParam) { + case _cmd_(IDC_SUSPEND, BN_CLICKED): + case _cmd_(IDC_SYSTEM_TRAY, BN_CLICKED): + case _cmd_(IDC_AC3_DEF, BN_CLICKED): + case _cmd_(IDC_MSN, BN_CLICKED): + PropSheet_Changed(GetParent(hDlg), hDlg); + return 0; + } + return FALSE; + + case WM_NOTIFY: + switch (((NMHDR FAR *) lParam)->code) { + case PSN_APPLY: // Application des changements + suspend_minimized = get_check(hDlg, IDC_SUSPEND); + minimize_system_tray = get_check(hDlg, IDC_SYSTEM_TRAY); + use_ac3 = get_check(hDlg, IDC_AC3_DEF); + use_msn = get_check(hDlg, IDC_MSN); + niData.update_state(); + return psn_result(hDlg, PSNRET_NOERROR); + } + return FALSE; + + default: + return FALSE; + } +} + +/** + * Fonction sélectionnant le répertoire initial lors de la demande d'un dossier + **/ +static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) +{ + if(uMsg == BFFM_INITIALIZED) + SendMessage(hWnd, BFFM_SETSELECTION, 1, lpData); + return 0; +} + +/*static*/ void do_select_dir(LPWSTR dir, LPCWSTR title) +{ + wchar_t display_name[MAX_PATH]; + BROWSEINFO bi = { + hMainWnd, // hwndOwner - Handle de la fenêtre + NULL, // pidlRoot - À partir de quel dossier faut-il rechercher ? + display_name, // pszDisplayName - Variable recevant le dossier sélectionné + title, // lpszTitle - Message à afficher dans la fenêtre + BIF_RETURNONLYFSDIRS, // ulFlags - N'afiche que les dossiers + BrowseCallbackProc, // lpfn - Adresse de la fonction de CallBack + (LPARAM)dir, // lParam - Paramètre passé à la fonction de CallBack + 0 // iImage + }; + + ShowCursor(TRUE); + + LPITEMIDLIST iil = SHBrowseForFolder(&bi); + + ShowCursor(FALSE); + + if (iil != NULL) { + SHGetPathFromIDList(iil, dir); + CoTaskMemFree(iil); + } +} + +static void change_dir(HWND hDlg, HWND hItem, LPCWSTR title) +{ + wchar_t dir[MAX_PATH], save_dir[MAX_PATH]; + + SendMessage(hItem, WM_GETTEXT, (WPARAM)_countof(dir), (LPARAM)dir); + wcscpy_s(save_dir, _countof(save_dir), dir); + do_select_dir(dir, title); + if (wcscmp(dir, save_dir)!=0) { + SendMessage(hItem, WM_SETTEXT, 0, (LPARAM)dir); + PropSheet_Changed(GetParent(hDlg), hDlg); + } +} + +static INT_PTR CALLBACK FoldersDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { + + static HWND hVideoDirItem = NULL; + static HWND hSshotDirItem = NULL; + + switch (uMsg) { + + case WM_INITDIALOG: + hVideoDirItem = GetDlgItem(hDlg, IDC_MPEG2_DIR_VIEW); + hSshotDirItem = GetDlgItem(hDlg, IDC_SCREENSHOTS_DIR_VIEW); + SendMessage(hVideoDirItem, WM_SETTEXT, 0, (LPARAM)video_dir); + SendMessage(hSshotDirItem, WM_SETTEXT, 0, (LPARAM)screenshots_dir); + return TRUE; + + case WM_COMMAND: + switch(wParam) { + case _cmd_(IDC_MPEG2_DIR, BN_CLICKED): + change_dir(hDlg, hVideoDirItem, + L"Choisissez le répertoire où seront enregistrées les vidéos :"); + return 0; + + case _cmd_(IDC_SCREENSHOTS_DIR, BN_CLICKED): + change_dir(hDlg, hSshotDirItem, + L"Choisissez le répertoire où seront enregistrées les captures d'écran :"); + return 0; + + } + return FALSE; + + case WM_NOTIFY: + switch (((NMHDR FAR *) lParam)->code) { + case PSN_APPLY: // Application des changements + SendMessage(hVideoDirItem, WM_GETTEXT, + _countof(video_dir), (LPARAM)video_dir); + SendMessage(hSshotDirItem, WM_SETTEXT, + _countof(screenshots_dir), (LPARAM)screenshots_dir); + return psn_result(hDlg, PSNRET_NOERROR); + } + return FALSE; + + default: + return FALSE; + } +} + +VOID do_config(HWND hwndOwner) +{ + const PROPSHEETPAGE psp[] = { + { // Page des ressources (cartes et codecs) + sizeof(PROPSHEETPAGE), // dwSize + PSP_USETITLE, // dwFlags + hAppInstance, // hInstance + {MAKEINTRESOURCE(IDD_CONFIG)}, // pszTemplate (union) + {NULL}, // pszIcon (union) + L"Pilotes", // pszTitle + DriversDialogProc, // pfnDlgProc + PROPSHEETMODE, // lParam + NULL // pfnCallback + }, + { // Page des répertoires + sizeof(PROPSHEETPAGE), // dwSize + PSP_USETITLE, // dwFlags + hAppInstance, // hInstance + {MAKEINTRESOURCE(IDD_FOLDERS)}, // pszTemplate (union) + {NULL}, // pszIcon (union) + L"Répertoires", // pszTitle + FoldersDialogProc, // pfnDlgProc + PROPSHEETMODE, // lParam + NULL // pfnCallback + }, + { // Page des options diverses + sizeof(PROPSHEETPAGE), // dwSize + PSP_USETITLE, // dwFlags + hAppInstance, // hInstance + {MAKEINTRESOURCE(IDD_OPTIONS)}, // pszTemplate (union) + {NULL}, // pszIcon (union) + L"Options", // pszTitle + OptionsDialogProc, // pfnDlgProc + PROPSHEETMODE, // lParam + NULL // pfnCallback + } + }; + // + const PROPSHEETHEADER psh = { + sizeof(PROPSHEETHEADER), // dwSize + PSH_PROPSHEETPAGE | PSH_NOCONTEXTHELP | PSH_PROPTITLE, // dwFlags + hwndOwner, // hwndParent + hAppInstance, // hInstance + {NULL}, // pszIcon (union) + L"PouchinTV Mod", // pszCaption + _countof(psp), // nPages + {0}, // nStartPage (union) + {(LPCPROPSHEETPAGE) &psp}, // ppsp (union) + NULL // pfnCallback + }; + // + PropertySheet(&psh); + save_config(); // sauvegarde la configuration + return; +} + +// Appel du dialogue de configuration en mode normal en attendant l'implémentation +// éventuelle d'un "wizard". +// Retourne IDOK si la configuration a été validée, IDCANCEL si elle a été annulée. +BYTE drivers_dialog() +{ + int res = + DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_CONFIG), hMainWnd, + DriversDialogProc, DIALOGMODE); + save_config(); // sauvegarde la configuration + return (BYTE) res; +} + +// Appel du dialogue de recherche des chaînes en mode normal en attendant l'implémentation +// éventuelle d'un "wizard". +// Retourne IDOK si la configuration a été validée, IDCANCEL ou IDABORT si elle a été annulée. +BYTE scan_dialog() +{ + int res = + DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_SCAN), hMainWnd, + ScanDialogProc, DIALOGMODE); + save_config(); // sauvegarde la configuration (le nom de ville peut avoir changé) + return (BYTE) res; +} Added: trunk/settings.h =================================================================== --- trunk/settings.h (rev 0) +++ trunk/settings.h 2007-10-12 08:32:18 UTC (rev 92) @@ -0,0 +1,44 @@ +/* + * settings.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#pragma once + +// Appel du dialogue de configuration en mode normal en attendant l'implémentation +// éventuelle d'un "wizard". +// Retourne IDOK si la configuration a été validée, IDCANCEL si elle a été annulée. +BYTE drivers_dialog(); + +// Appel du dialogue de recherche des chaînes en mode normal en attendant l'implémentation +// éventuelle d'un "wizard". +// Retourne IDOK si la configuration a été validée, IDCANCEL ou IDABORT si elle a été annulée. +BYTE scan_dialog(); + +// Appel du dialogue de choix des répertoires de capture en attendant qu'on supprime +// l'appel de cette fonction depuis les menus +void do_select_dir(LPWSTR dir, LPCWSTR title); + +VOID do_config(HWND hwndOwner); Added: trunk/trayicon.cpp =================================================================== --- trunk/trayicon.cpp (rev 0) +++ trunk/trayicon.cpp 2007-10-12 08:32:18 UTC (rev 92) @@ -0,0 +1,122 @@ +/* + * trayicon.cpp + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#include "base.h" +#include "main.h" + +#include "trayicon.h" + +MyNOTIFYICONDATA niData; + + +MyNOTIFYICONDATA::MyNOTIFYICONDATA() : + alreadyset(false) +{ + ZeroMemory(this, sizeof(NOTIFYICONDATA)); + cbSize = sizeof(NOTIFYICONDATA); +} + +bool MyNOTIFYICONDATA::notify(DWORD dwMessage) +{ + if (hMainWnd != NULL) { + hWnd = hMainWnd; + uID = MY_TRAY_ICON_ID; + myprintf(L"MyNOTIFYICONDATA::notify() - msg=%u, flg=0x%02x\n", dwMessage, uFlags); + return Shell_NotifyIcon(dwMessage, this)==TRUE; + } + return false; +} + +void MyNOTIFYICONDATA::set_tip() +{ + if (chaineCourante >= 0 && chaineCourante < (int)Canaux.size()) { + const Chaine & canal_courant = Canaux[chaineCourante]; + + swprintf_s(szTip, _countof(szTip), + L"%S - %S", canal_courant.nom, canal_courant.prog1.nom); + uFlags |= NIF_TIP; + } +} + +void MyNOTIFYICONDATA::set_icon() +{ + HICON hNewIcon = recording() ? hRecIcon : hPrgIcon; + + if (hNewIcon != NULL && hNewIcon != hIcon) { + hIcon = hNewIcon; + uFlags |= NIF_ICON; + } +} + +void MyNOTIFYICONDATA::enable() +{ + if (!alreadyset) { + uFlags = NIF_MESSAGE; + uCallbackMessage = MY_TRAY_ICON_MESSAGE; + set_icon(); + set_tip(); + if (notify(NIM_ADD)) + alreadyset = true; + } + +} + +void MyNOTIFYICONDATA::update_icon() +{ + if (alreadyset) { + uFlags = 0; + set_icon(); + notify(NIM_MODIFY); + } +} + +void MyNOTIFYICONDATA::update_tip() +{ + if (alreadyset) { + uFlags = 0; + set_tip(); + notify(NIM_MODIFY); + } +} + +void MyNOTIFYICONDATA::disable() +{ + if (alreadyset) { + notify(NIM_DELETE); + hIcon = NULL; + alreadyset = false; + } +} + +void MyNOTIFYICONDATA::update_state() +{ + if (minimize_system_tray) + enable(); + else + disable(); +} + Added: trunk/trayicon.h =================================================================== --- trunk/trayicon.h (rev 0) +++ trunk/trayicon.h 2007-10-12 08:32:18 UTC (rev 92) @@ -0,0 +1,48 @@ +/* + * trayicon.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#pragma once + +#include + +class MyNOTIFYICONDATA : private NOTIFYICONDATA +{ + bool alreadyset; + + bool notify(DWORD dwMessage); + void set_tip(); + void set_icon(); +public: + void enable(); + void disable(); + void update_icon(); + void update_tip(); + void update_state(); + MyNOTIFYICONDATA(); +}; + +extern MyNOTIFYICONDATA niData; From pouchintv-svn at baysse.fr Fri Oct 12 19:42:31 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Fri, 12 Oct 2007 19:42:31 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r93 - trunk Message-ID: <20071012174231.6EAA15F2DB@mail.baysse.fr> Author: gingko Date: 2007-10-12 19:42:30 +0200 (Fri, 12 Oct 2007) New Revision: 93 Modified: trunk/ini.cpp trunk/main.cpp trunk/main.h trunk/res.rc trunk/resource.h trunk/settings.cpp Log: Ajout d'une correction de fr?\195?\169quence ?\195?\160 la configuration du tuner, permettant ainsi d'ajuster la syntonisation des tuners qui pr?\195?\169sentent un d?\195?\169calage par rapport ?\195?\160 la fr?\195?\169quence qu'ils cherchent ?\195?\160 obtenir. Cette correction s'applique au moment de la recherche de cha?\195?\174nes, et s'ajoute ?\195?\160 l'offset d?\195?\169fini dans le fichier "chaines.ini". L'ajustement d'offset applicable ?\195?\160 certaines cartes dans la fonction "lit_fichier_scan" du fichier "ini.cpp" s'applique donc maintenant ?\195?\160 cette valeur, et a en cons?\195?\169quence ?\195?\169t?\195?\169 "recal?\195?\169" comme ?\195?\169tant une diff?\195?\169rence par rapport ?\195?\160 la valeur du fichier "config.ini". Cette derni?\195?\168re valeur ?\195?\169tant actuellement de 167 pour toutes les villes, 166 devient donc -1 et 167 devient 0. Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-12 08:32:18 UTC (rev 92) +++ trunk/ini.cpp 2007-10-12 17:42:30 UTC (rev 93) @@ -52,6 +52,47 @@ // Taille des images des chaines (largeur et longueur) #define TAILLE_IMAGE_CHAINE 16 +static wchar_t config_file[] = L"\\config.ini"; +static wchar_t ini_config[] = L"Config"; +#if _DEBUG +static wchar_t ini_filtre_MPEG2[] = L"Filtre MPEG2 (debug)"; +static wchar_t ini_filtre_audio[] = L"Filtre audio (debug)"; +static wchar_t ini_filtre_ac3[] = L"Filtre AC3 (debug)"; +#else // #if _DEBUG +static wchar_t ini_filtre_MPEG2[] = L"Filtre MPEG2"; +static wchar_t ini_filtre_audio[] = L"Filtre audio"; +static wchar_t ini_filtre_ac3[] = L"Filtre AC3"; +#endif // #if _DEBUG +static wchar_t ini_nom_ville[] = L"Ville"; +static wchar_t ini_strict[] = L"Recherche stricte"; +static wchar_t ini_chaine_courante[] = L"Index chaîne courante"; +static wchar_t ini_rep_video[] = L"Répertoire vidéo"; +static wchar_t ini_rep_screen[] = L"Répertoire screenshots"; +static wchar_t ini_priorite[] = L"Priorité"; +static wchar_t ini_tuner[] = L"Tuner TNT"; +static wchar_t ini_receiver[] = L"Récepteur TNT"; +static wchar_t ini_offset_tuner[] = L"Offset tuner"; +static wchar_t ini_msn[] = L"Envoie programme regardé à MSN"; +static wchar_t ini_always_on_top[] = L"Fenêtre toujours devant"; +static wchar_t ini_ac3_defaut[] = L"Utilise AC3 quand dispo"; +static wchar_t ini_suspend_minimized[] = L"Suspendre si minimisé"; +static wchar_t ini_minimize_system_tray[] = L"Minimiser dans le system tray"; + +static wchar_t ini_use_all_width[] = L"Utilise toute la largeur"; +static wchar_t ini_etirer_video[] = L"Étirer la vidéo"; +static wchar_t ini_zoom_ratio[] = L"Facteur de zoom"; + +static wchar_t ini_position_fenetre[]=L"Position fenêtre"; + +#if USE_CONSOLE==1 +static wchar_t ini_position_console[]=L"Position console"; +#endif // #if USE_CONSOLE==1 + +static wchar_t ini_volume[] = L"Volume"; + +static wchar_t ini_use_vmr_deinterlace[]=L"Utilise le désentrelacement du VMR"; +static wchar_t ini_etat_fenetre[]=L"État fenêtre"; + bool WindowPos::verifie() { RECT rect; @@ -158,34 +199,46 @@ return hImage; } +BOOL save_config_int(LPCWSTR lpKeyName, LONG value); // forward + void lit_fichier_scan(wchar_t * ville) { wchar_t fileName[MAX_PATH]; wcscpy_s(fileName, _countof(fileName), pouchindir_prog); wcscat_s(fileName, _countof(fileName), scan_ini); - UINT freq_offset = GetPrivateProfileInt(ville, L"Offset", 167, fileName); + int freq_offset = GetPrivateProfileInt(ville, L"Offset", 167, fileName); - if (freq_offset != 166 && wcsstr(nom_tuner, L"Hauppauge") != NULL) { - int res = MessageBox(hMainWnd, - L"L'offset recommandé pour une carte Hauppauge est 166.\nVoulez vous utiliser 166 ?", - L"Carte Hauppauge", MB_YESNO | MB_ICONQUESTION); + static struct SuggestedOffsets + { + LPCWSTR tuner; + int offset; + } tbl_offsets[] = + { + {L"Hauppauge", 0}, + {L"Cinergy", -1} + }; - if (res == IDYES) - freq_offset = 166; - } + for (int i=0; i<_countof(tbl_offsets); i++) { + const SuggestedOffsets sof = tbl_offsets[i]; - if (freq_offset != 167 && wcsstr(nom_tuner, L"Cinergy") != NULL) { - int res = MessageBox(hMainWnd, - L"L'offset recommandé pour une carte Cinergy est 167.\nVoulez vous utiliser 167 ?", - L"Carte Cinergy", MB_YESNO | MB_ICONQUESTION); + if (offset_tuner != sof.offset && wcsstr(nom_tuner, sof.tuner) != NULL) { + wchar_t ttl[64]; + wchar_t msg[128]; - if (res == IDYES) - freq_offset = 167; + swprintf_s(ttl, _countof(ttl), L"Carte %s", sof.tuner); + swprintf_s(msg, _countof(msg), + L"L'offset recommandé pour une carte %s est %i.\nVoulez vous utiliser %i ?", + sof.tuner, sof.offset, sof.offset); + if (MessageBox(hMainWnd, msg, ttl, MB_YESNO | MB_ICONQUESTION) == IDYES) { + offset_tuner = sof.offset; + save_config_int(ini_offset_tuner, offset_tuner); + } + } } freq_scan.clear(); - freq_offset += 306000; + freq_offset += 306000+offset_tuner; Frequence freq; @@ -200,8 +253,8 @@ freq.mhz = freq_canal(freq.canal_no); freq_scan.push_back(freq); } - }else { - // Sinon, on récupère les canaux dans le fichier "canaux.ini" + } else { + // Sinon, on récupère les canaux dans le fichier "canaux.ini" wchar_t id_multiplex[4]; UINT nr_multiplex = 1; do { @@ -532,46 +585,6 @@ } -static wchar_t config_file[] = L"\\config.ini"; -static wchar_t ini_config[] = L"Config"; -#if _DEBUG -static wchar_t ini_filtre_MPEG2[] = L"Filtre MPEG2 (debug)"; -static wchar_t ini_filtre_audio[] = L"Filtre audio (debug)"; -static wchar_t ini_filtre_ac3[] = L"Filtre AC3 (debug)"; -#else // #if _DEBUG -static wchar_t ini_filtre_MPEG2[] = L"Filtre MPEG2"; -static wchar_t ini_filtre_audio[] = L"Filtre audio"; -static wchar_t ini_filtre_ac3[] = L"Filtre AC3"; -#endif // #if _DEBUG -static wchar_t ini_nom_ville[] = L"Ville"; -static wchar_t ini_strict[] = L"Recherche stricte"; -static wchar_t ini_chaine_courante[] = L"Index chaîne courante"; -static wchar_t ini_rep_video[] = L"Répertoire vidéo"; -static wchar_t ini_rep_screen[] = L"Répertoire screenshots"; -static wchar_t ini_priorite[] = L"Priorité"; -static wchar_t ini_tuner[] = L"Tuner TNT"; -static wchar_t ini_receiver[] = L"Récepteur TNT"; -static wchar_t ini_msn[] = L"Envoie programme regardé à MSN"; -static wchar_t ini_always_on_top[] = L"Fenêtre toujours devant"; -static wchar_t ini_ac3_defaut[] = L"Utilise AC3 quand dispo"; -static wchar_t ini_suspend_minimized[] = L"Suspendre si minimisé"; -static wchar_t ini_minimize_system_tray[] = L"Minimiser dans le system tray"; - -static wchar_t ini_use_all_width[] = L"Utilise toute la largeur"; -static wchar_t ini_etirer_video[] = L"Étirer la vidéo"; -static wchar_t ini_zoom_ratio[] = L"Facteur de zoom"; - -static wchar_t ini_position_fenetre[]=L"Position fenêtre"; - -#if USE_CONSOLE==1 -static wchar_t ini_position_console[]=L"Position console"; -#endif // #if USE_CONSOLE==1 - -static wchar_t ini_volume[] = L"Volume"; - -static wchar_t ini_use_vmr_deinterlace[]=L"Utilise le désentrelacement du VMR"; -static wchar_t ini_etat_fenetre[]=L"État fenêtre"; - struct AssocElement { LPCWSTR str; @@ -658,6 +671,7 @@ save_config_str(ini_tuner, nom_tuner); save_config_str(ini_receiver, nom_receiver); + save_config_int(ini_offset_tuner, offset_tuner); save_config_str(ini_filtre_MPEG2, filtreMPEG2); save_config_str(ini_filtre_audio, filtreAudio); save_config_str(ini_filtre_ac3, filtreAc3); @@ -764,6 +778,7 @@ load_config_str(ini_receiver, nom_receiver, _countof(nom_receiver)); load_config_str(ini_filtre_MPEG2, filtreMPEG2, _countof(filtreMPEG2)); + offset_tuner = load_config_int(ini_offset_tuner, 0); load_config_str(ini_filtre_audio, filtreAudio, _countof(filtreAudio)); load_config_str(ini_filtre_ac3, filtreAc3, _countof(filtreAc3)); load_config_str(ini_nom_ville, nomVille, _countof(nomVille)); Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-10-12 08:32:18 UTC (rev 92) +++ trunk/main.cpp 2007-10-12 17:42:30 UTC (rev 93) @@ -72,6 +72,7 @@ wchar_t nom_tuner[256]; wchar_t nom_receiver[256]; +int offset_tuner; wchar_t screenshots_dir[MAX_PATH]; wchar_t video_dir[MAX_PATH]; Modified: trunk/main.h =================================================================== --- trunk/main.h 2007-10-12 08:32:18 UTC (rev 92) +++ trunk/main.h 2007-10-12 17:42:30 UTC (rev 93) @@ -38,6 +38,7 @@ extern wchar_t screenshots_dir[MAX_PATH]; extern wchar_t video_dir[MAX_PATH]; +extern int offset_tuner; extern bool suspend_minimized; extern bool minimize_system_tray; Modified: trunk/res.rc =================================================================== --- trunk/res.rc 2007-10-12 08:32:18 UTC (rev 92) +++ trunk/res.rc 2007-10-12 17:42:30 UTC (rev 93) @@ -145,18 +145,21 @@ CAPTION "Configuration" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - GROUPBOX "Configuration matérielle",IDC_STATIC,7,7,276,52 + GROUPBOX "Configuration matérielle",IDC_STATIC,7,7,276,68 LTEXT "Tuner TNT",IDC_STATIC,14,20,55,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO_TUNER,76,20,200,100,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP LTEXT "Récepteur TNT",IDC_STATIC,14,36,55,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO_RECEIVER,76,36,200,100,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Codecs utilisés",IDC_STATIC,7,63,276,84 - LTEXT "Codec MPEG2",IDC_STATIC,14,76,55,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_MPEG2,76,76,200,100,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - LTEXT "Codec Audio",IDC_STATIC,14,108,55,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_AUDIO,76,108,200,100,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - LTEXT "Codec AC3",IDC_STATIC,14,124,55,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_AC3,76,124,200,100,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + RTEXT "Correction de fréquence du tuner (kHz) :",IDC_STATIC,76,57,156,8 + EDITTEXT IDC_TUNER_OFFSET,240,54,36,14,ES_CENTER | ES_AUTOHSCROLL + CONTROL "",IDC_TUNER_OFFSET_UPDOWN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,265,54,10,14 + GROUPBOX "Codecs utilisés",IDC_STATIC,7,86,276,84 + LTEXT "Codec MPEG2",IDC_STATIC,14,100,55,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_MPEG2,76,100,200,100,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Codec Audio",IDC_STATIC,14,132,55,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_AUDIO,76,132,200,100,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Codec AC3",IDC_STATIC,14,148,55,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_AC3,76,148,200,100,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP DEFPUSHBUTTON "OK",IDOK,88,193,54,14 PUSHBUTTON "Annuler",IDCANCEL,148,193,54,14 END @@ -299,7 +302,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CTEXT "Veuillez entrer le mot de passe du compte windows (nécessaire pour l'ajout de la tâche planifiée)",IDC_STATIC,7,7,136,28 - EDITTEXT IDC_PASWD,29,35,92,12,ES_PASSWORD | ES_AUTOHSCROLL | WS_TABSTOP + EDITTEXT IDC_PASWD,29,35,92,12,ES_PASSWORD | ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,7,54,54,14 PUSHBUTTON "Annuler",IDCANCEL,89,54,54,14 END Modified: trunk/resource.h =================================================================== --- trunk/resource.h 2007-10-12 08:32:18 UTC (rev 92) +++ trunk/resource.h 2007-10-12 17:42:30 UTC (rev 93) @@ -31,6 +31,8 @@ #define IDC_POUCHINTV_URL 1008 #define IDC_COMBO_TUNER 1009 #define IDC_COMBO_RECEIVER 1010 +#define IDC_TUNER_OFFSET 1011 +#define IDC_TUNER_OFFSET_UPDOWN 1012 #define IDC_LIST_EPG 1013 #define IDC_UPDATE 1014 #define IDC_SIGNAL_PRESENT 1015 Modified: trunk/settings.cpp =================================================================== --- trunk/settings.cpp 2007-10-12 08:32:18 UTC (rev 92) +++ trunk/settings.cpp 2007-10-12 17:42:30 UTC (rev 93) @@ -85,12 +85,19 @@ bool drivers_apply(HWND hDlg) { bool changed = false; + BOOL valid = false; changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_TUNER), nom_tuner, _countof(nom_tuner)); changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_RECEIVER), nom_receiver, _countof(nom_receiver)); changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_MPEG2), filtreMPEG2, _countof(filtreMPEG2)); changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_AUDIO), filtreAudio, _countof(filtreAudio)); changed |= extrait_combo(GetDlgItem(hDlg, IDC_COMBO_AC3), filtreAc3, _countof(filtreAc3)); + + // La valeur suivante n'est pas prise en compte dans le résultat de la fonction : + int res = (int)GetDlgItemInt(hDlg, IDC_TUNER_OFFSET, &valid, TRUE); + if (valid) + offset_tuner = res; + myprintf(L"Video : %s\nAudio : %s\nAc3 : %s\n", filtreMPEG2, filtreAudio, filtreAc3); return changed; } @@ -115,11 +122,30 @@ MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO, filtreAudio); remplit_combo_filtre(GetDlgItem(hDlg, IDC_COMBO_AC3), MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3, filtreAc3); + SetDlgItemInt(hDlg, IDC_TUNER_OFFSET, (UINT)offset_tuner, TRUE); + SendDlgItemMessage(hDlg, IDC_TUNER_OFFSET_UPDOWN, UDM_SETRANGE, 0, + MAKELPARAM((short)999, (short)-999)); return TRUE; case WM_COMMAND: switch(wParam) { + case _cmd_(IDC_TUNER_OFFSET, EN_CHANGE): { + BOOL valid = false; + int res = (int)GetDlgItemInt(hDlg, IDC_TUNER_OFFSET, &valid, TRUE); + if (valid) { + if (res<-999) { + res = -999; + valid = FALSE; + } else if (res>999) { + res = 999; + valid = FALSE; + } + } + if (!valid) + SetDlgItemInt(hDlg, IDC_TUNER_OFFSET, (UINT)res, TRUE); + } + // ... case _cmd_(IDC_COMBO_TUNER, LBN_SELCHANGE): case _cmd_(IDC_COMBO_RECEIVER, LBN_SELCHANGE): case _cmd_(IDC_COMBO_MPEG2, LBN_SELCHANGE): From pouchintv-svn at baysse.fr Sun Oct 14 16:09:10 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Sun, 14 Oct 2007 16:09:10 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r94 - trunk Message-ID: <20071014140910.AB5C35F2E3@mail.baysse.fr> Author: gingko Date: 2007-10-14 16:09:10 +0200 (Sun, 14 Oct 2007) New Revision: 94 Modified: trunk/Hyperlinks.h trunk/LCD.cpp trunk/LCD.h trunk/base.h trunk/crc32.cpp trunk/crc32.h trunk/epg.cpp trunk/epg.h trunk/epgfilter.cpp trunk/epgfilter.h trunk/grabber.h trunk/graph.h trunk/ini.cpp trunk/ini.h trunk/internet.h trunk/main.cpp trunk/main.h trunk/network.h trunk/parse.h trunk/pmtfilter.h trunk/search.h trunk/trayicon.cpp trunk/xml.cpp trunk/xml.h Log: Dans la structure 'struct Chaine', les deux champs 'prog1' et 'prog2' sont remplac?\195?\169s par un tableau 'emis[2]', afin d'en permettre l'utilisation future par index ainsi que de mieux distinguer entre 'emis' = ?\195?\169mission et 'prog' = enregistrement programm?\195?\169, un peu partout dans le code. En cons?\195?\169quence, 'prog1' devient 'emis[0]' et 'prog2' devient 'emis[1]'. Factorisation dans ini.cpp. Ajout de commentaire d'en-t?\195?\170te GPL dans les fichiers o?\195?\185 il en manquait, et notamment dans les fichiers .h. Modified: trunk/Hyperlinks.h =================================================================== --- trunk/Hyperlinks.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/Hyperlinks.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,3 +1,32 @@ +/* + * Hyperlinks.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#pragma once + // Hyperlinks.h // // Copyright 2002 Neal Stublen Modified: trunk/LCD.cpp =================================================================== --- trunk/LCD.cpp 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/LCD.cpp 2007-10-14 14:09:10 UTC (rev 94) @@ -22,7 +22,7 @@ // Peut être testé par tous // -// Il faut simplement installé les pilotes du clavier logitech G15 ou des enceintes Z10 +// Il faut simplement installer les pilotes du clavier logitech G15 ou des enceintes Z10 #include #include Modified: trunk/LCD.h =================================================================== --- trunk/LCD.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/LCD.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,4 +1,32 @@ +/* + * LCD.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + #include "LCD_Logitech/lglcd.h" class CLcd { Modified: trunk/base.h =================================================================== --- trunk/base.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/base.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,6 +1,30 @@ +/* + * base.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ -#ifndef BASE_H -#define BASE_H #pragma once // Utiliser VMR9 @@ -234,8 +258,7 @@ WORD canal_no; long frequence; WORD pmt_pid; - Emission prog1; - Emission prog2; + Emission emis[2]; private: HBITMAP hImage; public: @@ -263,5 +286,3 @@ etf_fullscreen, // plein écran (sans bordures) etf_minimized // minimisée (en icône ou pas) }; - -#endif // #ifndef BASE_H Modified: trunk/crc32.cpp =================================================================== --- trunk/crc32.cpp 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/crc32.cpp 2007-10-14 14:09:10 UTC (rev 94) @@ -1,3 +1,29 @@ +/* + * crc32.cpp + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ // CRC32 lookup table for polynomial 0x04c11db7 // coming from http://dvbsnoop.sourceforge.net/ Modified: trunk/crc32.h =================================================================== --- trunk/crc32.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/crc32.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,2 +1,30 @@ +/* + * crc.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + bool check_crc32(unsigned char * data, long len); Modified: trunk/epg.cpp =================================================================== --- trunk/epg.cpp 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/epg.cpp 2007-10-14 14:09:10 UTC (rev 94) @@ -46,7 +46,7 @@ for (size_t i=0; i 0) { erreur(L"Le programme commence après avoir fini !"); @@ -287,7 +287,7 @@ return FALSE; case WM_CLOSE: - DestroyWindow(hwndDlg); + DestroyWindow(hDlg); return TRUE; case WM_NCDESTROY: hEpgDlg = NULL; Modified: trunk/epg.h =================================================================== --- trunk/epg.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/epg.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,3 +1,32 @@ +/* + * epg.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#pragma once + extern HWND hEpgDlg; INT_PTR CALLBACK EpgDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); Modified: trunk/epgfilter.cpp =================================================================== --- trunk/epgfilter.cpp 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/epgfilter.cpp 2007-10-14 14:09:10 UTC (rev 94) @@ -130,20 +130,20 @@ Chaine & chaine = Canaux[chaineEit]; - if (debut.QuadPart == chaine.prog1.debut.QuadPart) + if (debut.QuadPart == chaine.emis[0].debut.QuadPart) { // we already know that emission - chaine.prog1.latest = true; - chaine.prog2.latest = false; + chaine.emis[0].latest = true; + chaine.emis[1].latest = false; offset += 12 + len; continue; } - if (debut.QuadPart == chaine.prog2.debut.QuadPart) + if (debut.QuadPart == chaine.emis[1].debut.QuadPart) { // we already know that emission - chaine.prog1.latest = false; - chaine.prog2.latest = true; + chaine.emis[0].latest = false; + chaine.emis[1].latest = true; offset += 12 + len; continue; } @@ -214,50 +214,50 @@ // myprintf(L"%S : %S : %S\n", chaine.nom, emi.debut_str, emi.nom); // faut placer l'émission maintenant - if (chaine.prog1.debut.QuadPart == 0) { + if (chaine.emis[0].debut.QuadPart == 0) { // c'est la 1ère recensée - chaine.prog1 = emi; - } else if (chaine.prog2.debut.QuadPart == 0) { + chaine.emis[0] = emi; + } else if (chaine.emis[1].debut.QuadPart == 0) { // c'est la 2ème recensée - if( debut.QuadPart > chaine.prog1.debut.QuadPart) + if( debut.QuadPart > chaine.emis[0].debut.QuadPart) { - chaine.prog2 = emi; - chaine.prog1.latest = false; + chaine.emis[1] = emi; + chaine.emis[0].latest = false; } else { - chaine.prog2 = chaine.prog1; - chaine.prog1 = emi; + chaine.emis[1] = chaine.emis[0]; + chaine.emis[0] = emi; - chaine.prog2.latest = false; + chaine.emis[1].latest = false; } } else { // on vire l'emission qui est pas la latest - if (chaine.prog1.latest) + if (chaine.emis[0].latest) { // on vire la 2 - chaine.prog2 = emi; - chaine.prog1.latest = false; + chaine.emis[1] = emi; + chaine.emis[0].latest = false; } else { // on vire la 1 - chaine.prog1 = emi; - chaine.prog2.latest = false; + chaine.emis[0] = emi; + chaine.emis[1].latest = false; } // on remet dans l'ordre si nécessaire - if ( chaine.prog1.debut.QuadPart > chaine.prog2.debut.QuadPart) + if ( chaine.emis[0].debut.QuadPart > chaine.emis[1].debut.QuadPart) { - Emission tmp = chaine.prog1; - chaine.prog1 = chaine.prog2; - chaine.prog2 = tmp; + Emission tmp = chaine.emis[0]; + chaine.emis[0] = chaine.emis[1]; + chaine.emis[1] = tmp; } } Modified: trunk/epgfilter.h =================================================================== --- trunk/epgfilter.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/epgfilter.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,4 +1,32 @@ +/* + * epgfilter.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + #include class CEPGFilter : public CBaseRenderer Modified: trunk/grabber.h =================================================================== --- trunk/grabber.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/grabber.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,6 +1,32 @@ +/* + * grabber.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once - class CSampleGrabber : public CUnknown, public ISampleGrabberCB // The Filter Interface { Modified: trunk/graph.h =================================================================== --- trunk/graph.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/graph.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,4 +1,32 @@ +/* + * graph.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + int build_graph(void); // retourne 0 = pas d'erreur, 1 = erreur void clean_dshow(void); int init_vmr(void); Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/ini.cpp 2007-10-14 14:09:10 UTC (rev 94) @@ -270,8 +270,69 @@ } } +static LPCWSTR Tbl_DoW[7] = { + L"Dimanche", + L"Lundi", + L"Mardi", + L"Mercredi", + L"Jeudi", + L"Vendredi", + L"Samedi" +}; + +struct XMLSystemTimeNames { + LPCWSTR name_wYear; + LPCWSTR name_wMonth; + LPCWSTR name_wDayOfWeek; + LPCWSTR name_wDay; + LPCWSTR name_wHour; + LPCWSTR name_wMinute; + LPCWSTR name_wSecond; +}; + +void xmlLoadSystemTime(CXMLNode * pNode, SYSTEMTIME & stim, const XMLSystemTimeNames & xstn) +{ + stim.wYear = (WORD)pNode->getInt(xstn.name_wYear); + stim.wMonth = (WORD)pNode->getInt(xstn.name_wMonth); + stim.wDayOfWeek = (WORD)pNode->getInt(xstn.name_wDayOfWeek); + stim.wDay = (WORD)pNode->getInt(xstn.name_wDay); + stim.wHour = (WORD)pNode->getInt(xstn.name_wHour); + stim.wMinute = (WORD)pNode->getInt(xstn.name_wMinute); + stim.wSecond = (WORD)pNode->getInt(xstn.name_wSecond); +} + int lit_programmes(void) { + static const XMLSystemTimeNames Xstn_std = { + L"Annee", + L"Mois", + L"Jour_Semaine", + L"Jour", + L"Heure", + L"Minute", + L"Seconde" + }; + + static const XMLSystemTimeNames Xstn_S = { + L"S_Annee", + L"S_Mois", + L"S_Jour_semaine", + L"S_Jour", + L"S_Heure", + L"S_Minute", + L"S_Seconde" + }; + + static const XMLSystemTimeNames Xstn_E = { + L"E_Annee", + L"E_Mois", + L"E_Jour_semaine", + L"E_Jour", + L"E_Heure", + L"E_Minute", + L"E_Seconde" + }; + Programmes.clear(); CXMLWrapper xml; @@ -304,47 +365,21 @@ CXMLNode *enregistrements = NULL; pNode->getChildrenByName(L"Début", &enregistrements); if (enregistrements) { - prog.debut.wYear = (WORD)enregistrements->getInt(L"Annee"); - prog.debut.wMonth = (WORD)enregistrements->getInt(L"Mois"); - prog.debut.wDayOfWeek = (WORD)enregistrements->getInt(L"Jour_Semaine"); - prog.debut.wDay = (WORD)enregistrements->getInt(L"Jour"); - prog.debut.wHour = (WORD)enregistrements->getInt(L"Heure"); - prog.debut.wMinute = (WORD)enregistrements->getInt(L"Minute"); - prog.debut.wSecond = (WORD)enregistrements->getInt(L"Seconde"); - + xmlLoadSystemTime(enregistrements, prog.debut, Xstn_std); delete enregistrements; enregistrements = NULL; } else { - prog.debut.wYear = (WORD)pNode->getInt(L"S_Annee"); - prog.debut.wMonth = (WORD)pNode->getInt(L"S_Mois"); - prog.debut.wDayOfWeek = (WORD)pNode->getInt(L"S_Jour_semaine"); - prog.debut.wDay = (WORD)pNode->getInt(L"S_Jour"); - prog.debut.wHour = (WORD)pNode->getInt(L"S_Heure"); - prog.debut.wMinute = (WORD)pNode->getInt(L"S_Minute"); - prog.debut.wSecond = (WORD)pNode->getInt(L"S_Seconde"); + xmlLoadSystemTime(pNode, prog.debut, Xstn_S); } // Récupère les heures/dates de fin d'enregistrement pNode->getChildrenByName(L"Fin", &enregistrements); if (enregistrements) { - prog.fin.wYear = (WORD)enregistrements->getInt(L"Annee"); - prog.fin.wMonth = (WORD)enregistrements->getInt(L"Mois"); - prog.fin.wDayOfWeek = (WORD)enregistrements->getInt(L"Jour_Semaine"); - prog.fin.wDay = (WORD)enregistrements->getInt(L"Jour"); - prog.fin.wHour = (WORD)enregistrements->getInt(L"Heure"); - prog.fin.wMinute = (WORD)enregistrements->getInt(L"Minute"); - prog.fin.wSecond = (WORD)enregistrements->getInt(L"Seconde"); - + xmlLoadSystemTime(enregistrements, prog.fin, Xstn_std); delete enregistrements; enregistrements = NULL; } else { - prog.fin.wYear = (WORD)pNode->getInt(L"E_Annee"); - prog.fin.wMonth = (WORD)pNode->getInt(L"E_Mois"); - prog.fin.wDayOfWeek = (WORD)pNode->getInt(L"E_Jour_semaine"); - prog.fin.wDay = (WORD)pNode->getInt(L"E_Jour"); - prog.fin.wHour = (WORD)pNode->getInt(L"E_Heure"); - prog.fin.wMinute = (WORD)pNode->getInt(L"E_Minute"); - prog.fin.wSecond = (WORD)pNode->getInt(L"E_Seconde"); + xmlLoadSystemTime(pNode, prog.fin, Xstn_E); } prog.methode = (MethodeEnregistrement)pNode->getInt(L"Methode"); @@ -356,13 +391,8 @@ pNode->getChildrenByName(L"Repetitions", &repetitions); // Au cas où on passe d'une ancienne version ne supportant pas les répétitions if (repetitions) { - prog.repetition[1] = repetitions->getInt(L"Lundi")!=0; - prog.repetition[2] = repetitions->getInt(L"Mardi")!=0; - prog.repetition[3] = repetitions->getInt(L"Mercredi")!=0; - prog.repetition[4] = repetitions->getInt(L"Jeudi")!=0; - prog.repetition[5] = repetitions->getInt(L"Vendredi")!=0; - prog.repetition[6] = repetitions->getInt(L"Samedi")!=0; - prog.repetition[0] = repetitions->getInt(L"Dimanche")!=0; + for (int j=0; j<7; j++) + prog.repetition[j] = repetitions->getInt(Tbl_DoW[j])!=0; delete repetitions; repetitions = NULL; @@ -377,6 +407,24 @@ return 0; } +void xmlSaveSystemTime(FILE * fop, LPCSTR section, const SYSTEMTIME & stim) +{ + fprintf(fop, + "\t\t<%s>\n" + "\t\t\t%i\n" + "\t\t\t%i\n" + "\t\t\t%i\n" + "\t\t\t%i\n" + "\t\t\t%i\n" + "\t\t\t%i\n" + "\t\t\t%i\n" + "\t\t\n", + section, + stim.wYear, stim.wMonth, stim.wDayOfWeek, stim.wDay, + stim.wHour, stim.wMinute, stim.wSecond, + section); +} + void sauve_programmes(void) { int nbProgrammes = (int)Programmes.size(); @@ -395,48 +443,32 @@ for (int i=0; i\n"); + fprintf(fop, + "\t\n" + "\t\t%s\n" + "\t\t%i\n", + programme.nom, programme.chaine); - fprintf(fop, "\t\t%s\n", programme.nom); + xmlSaveSystemTime(fop, "Début", programme.debut); + xmlSaveSystemTime(fop, "Fin", programme.fin); - fprintf(fop, "\t\t%i\n", programme.chaine); + fprintf(fop, + "\t\t%i\n" + "\t\t\n" + "\t\t%i\n" + "\t\t%i\n" + "\t\t\n", + programme.methode, programme.audio, programme.after, programme.tache); - fprintf(fop, "\t\t\n"); - fprintf(fop, "\t\t\t%i\n", programme.debut.wYear); - fprintf(fop, "\t\t\t%i\n", programme.debut.wMonth); - fprintf(fop, "\t\t\t%i\n", programme.debut.wDayOfWeek); - fprintf(fop, "\t\t\t%i\n", programme.debut.wDay); - fprintf(fop, "\t\t\t%i\n", programme.debut.wHour); - fprintf(fop, "\t\t\t%i\n", programme.debut.wMinute); - fprintf(fop, "\t\t\t%i\n", programme.debut.wSecond); - fprintf(fop, "\t\t\n"); + for (int j=0; j<7; j++) { + LPCWSTR dow = Tbl_DoW[j]; - fprintf(fop, "\t\t\n"); - fprintf(fop, "\t\t\t%i\n", programme.fin.wYear); - fprintf(fop, "\t\t\t%i\n", programme.fin.wMonth); - fprintf(fop, "\t\t\t%i\n", programme.fin.wDayOfWeek); - fprintf(fop, "\t\t\t%i\n", programme.fin.wDay); - fprintf(fop, "\t\t\t%i\n", programme.fin.wHour); - fprintf(fop, "\t\t\t%i\n", programme.fin.wMinute); - fprintf(fop, "\t\t\t%i\n", programme.fin.wSecond); - fprintf(fop, "\t\t\n"); + fprintf(fop, "\t\t\t<%S>%i\n", dow, programme.repetition[j], dow); + } - fprintf(fop, "\t\t%i\n", programme.methode); - fprintf(fop, "\t\t\n", programme.audio); - fprintf(fop, "\t\t%i\n", programme.after); - fprintf(fop, "\t\t%i\n", programme.tache); - - fprintf(fop, "\t\t\n"); - fprintf(fop, "\t\t\t%i\n", programme.repetition[1]); - fprintf(fop, "\t\t\t%i\n", programme.repetition[2]); - fprintf(fop, "\t\t\t%i\n", programme.repetition[3]); - fprintf(fop, "\t\t\t%i\n", programme.repetition[4]); - fprintf(fop, "\t\t\t%i\n", programme.repetition[5]); - fprintf(fop, "\t\t\t%i\n", programme.repetition[6]); - fprintf(fop, "\t\t\t%i\n", programme.repetition[0]); - fprintf(fop, "\t\t\n"); - - fprintf(fop, "\t\n"); + fprintf(fop, + "\t\t\n", + "\t\n"); } fprintf(fop, "\n"); Modified: trunk/ini.h =================================================================== --- trunk/ini.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/ini.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,4 +1,32 @@ +/* + * ini.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + void lit_fichier_scan(wchar_t * ville); int lit_chaines(void); void sauve_chaines(void); Modified: trunk/internet.h =================================================================== --- trunk/internet.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/internet.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,6 +1,32 @@ -#ifndef _INTERNET_H_ -#define _INTERNET_H_ +/* + * internet.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + // URL pour la mise à jour #define UPDATE_URL (L"http://pouchintv.baysse.fr/version.php") @@ -56,7 +82,4 @@ // Etablie la connexion int EtablieConnexion(); -}; - - -#endif // _INTERNET_H_ \ No newline at end of file +}; \ No newline at end of file Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/main.cpp 2007-10-14 14:09:10 UTC (rev 94) @@ -1019,10 +1019,10 @@ if (hStatus != NULL) { SendMessageA(hStatus, SB_SETTEXTA, 0, (LPARAM)canal_courant.nom); - SendMessageA(hStatus, SB_SETTEXTA, 1, (LPARAM)canal_courant.prog1.debut_str); - SendMessageA(hStatus, SB_SETTEXTA, 2, (LPARAM)canal_courant.prog1.nom); - SendMessageA(hStatus, SB_SETTEXTA, 3, (LPARAM)canal_courant.prog2.debut_str); - SendMessageA(hStatus, SB_SETTEXTA, 4, (LPARAM)canal_courant.prog2.nom); + SendMessageA(hStatus, SB_SETTEXTA, 1, (LPARAM)canal_courant.emis[0].debut_str); + SendMessageA(hStatus, SB_SETTEXTA, 2, (LPARAM)canal_courant.emis[0].nom); + SendMessageA(hStatus, SB_SETTEXTA, 3, (LPARAM)canal_courant.emis[1].debut_str); + SendMessageA(hStatus, SB_SETTEXTA, 4, (LPARAM)canal_courant.emis[1].nom); if (is_vista) { if (!muted) @@ -1037,14 +1037,14 @@ // Le LCD est OK if (lcd.IsInitialise()) { lcd.SetChaine(canal_courant.nom); - lcd.SetProgrammeActuel(canal_courant.prog1.debut_str, canal_courant.prog1.nom); - lcd.SetProgrammeSuivant(canal_courant.prog2.debut_str, canal_courant.prog2.nom); + lcd.SetProgrammeActuel(canal_courant.emis[0].debut_str, canal_courant.emis[0].nom); + lcd.SetProgrammeSuivant(canal_courant.emis[1].debut_str, canal_courant.emis[1].nom); lcd.SetVolume(volumeCourant); lcd.ActualiseLcd(); } #endif // #ifdef USE_LOGITECH_LCD - if (use_msn && canal_courant.prog1.debut.QuadPart != 0) { + if (use_msn && canal_courant.emis[0].debut.QuadPart != 0) { HWND msnui = FindWindow(L"MsnMsgrUIManager", NULL); if (msnui != NULL) @@ -1052,7 +1052,7 @@ COPYDATASTRUCT msndata; WCHAR buffer[1024]; - swprintf_s(buffer, _countof(buffer), L"\\0Music\\01\\0{0} - {1}\\0%S\\0%S\\0\\0\\0", canal_courant.nom, canal_courant.prog1.nom); + swprintf_s(buffer, _countof(buffer), L"\\0Music\\01\\0{0} - {1}\\0%S\\0%S\\0\\0\\0", canal_courant.nom, canal_courant.emis[0].nom); msndata.dwData = 0x547; msndata.lpData = &buffer; @@ -2924,8 +2924,8 @@ TextOutA(hdc, rect.right-10, rect.top, ch.nom, (int)strlen(ch.nom)); - if (ch.prog1.debut.QuadPart) { - TextOutA(hdc, rect.right-10, rect.top+hauteur, ch.prog1.nom, (int)strlen(ch.prog1.nom)); + if (ch.emis[0].debut.QuadPart) { + TextOutA(hdc, rect.right-10, rect.top+hauteur, ch.emis[0].nom, (int)strlen(ch.emis[0].nom)); } } Modified: trunk/main.h =================================================================== --- trunk/main.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/main.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,4 +1,32 @@ +/* + * main.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + // Nom de l'application extern wchar_t szAppName[]; Modified: trunk/network.h =================================================================== --- trunk/network.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/network.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,4 +1,32 @@ +/* + * network.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + #include #include Modified: trunk/parse.h =================================================================== --- trunk/parse.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/parse.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,3 +1,32 @@ +/* + * parse.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#pragma once + struct PMT; void parse_pmt(const PMT * ppmt, int max, ChainePMT & pmt/*, bool debug*/); Modified: trunk/pmtfilter.h =================================================================== --- trunk/pmtfilter.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/pmtfilter.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,4 +1,32 @@ +/* + * pmtfilter.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + #include class CPMTFilter : public CBaseRenderer Modified: trunk/search.h =================================================================== --- trunk/search.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/search.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,4 +1,32 @@ +/* + * search.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ +#pragma once + //IBaseFilter * search_mpeg2(IEnumMoniker *pEnumMoniker, GUID subtype, GUID format); IPin * cherche_pin(IBaseFilter * pFilter, PIN_DIRECTION dir); Modified: trunk/trayicon.cpp =================================================================== --- trunk/trayicon.cpp 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/trayicon.cpp 2007-10-14 14:09:10 UTC (rev 94) @@ -57,7 +57,7 @@ const Chaine & canal_courant = Canaux[chaineCourante]; swprintf_s(szTip, _countof(szTip), - L"%S - %S", canal_courant.nom, canal_courant.prog1.nom); + L"%S - %S", canal_courant.nom, canal_courant.emis[0].nom); uFlags |= NIF_TIP; } } Modified: trunk/xml.cpp =================================================================== --- trunk/xml.cpp 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/xml.cpp 2007-10-14 14:09:10 UTC (rev 94) @@ -24,6 +24,7 @@ * a modified version of this software. * See http://pouchintv.baysse.fr/ for updates. */ + #include "base.h" #include "xml.h" Modified: trunk/xml.h =================================================================== --- trunk/xml.h 2007-10-12 17:42:30 UTC (rev 93) +++ trunk/xml.h 2007-10-14 14:09:10 UTC (rev 94) @@ -1,3 +1,32 @@ +/* + * xml.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#pragma once + #include #include From pouchintv-svn at baysse.fr Sun Oct 14 20:33:26 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Sun, 14 Oct 2007 20:33:26 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r95 - trunk Message-ID: <20071014183327.157B45F2E3@mail.baysse.fr> Author: gingko Date: 2007-10-14 20:33:26 +0200 (Sun, 14 Oct 2007) New Revision: 95 Modified: trunk/ini.cpp Log: Petite erreur de ma part. (juste une virgule, mais qui est suffisante pour emp?\195?\170cher la programmation des enregistrements) Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-14 14:09:10 UTC (rev 94) +++ trunk/ini.cpp 2007-10-14 18:33:26 UTC (rev 95) @@ -467,7 +467,7 @@ } fprintf(fop, - "\t\t\n", + "\t\t\n" "\t\n"); } From gingko_pouchintv at nospam.homelinux.org Mon Oct 15 00:45:50 2007 From: gingko_pouchintv at nospam.homelinux.org (Gingko) Date: Mon, 15 Oct 2007 00:45:50 +0200 Subject: [Pouchintv-dev] r96 ? References: <20071014183327.157B45F2E3@mail.baysse.fr> Message-ID: <002201c80eb3$f8843d50$0a00a8c0@gilles> Bonjour, Je me trompe, ou bien le message automatique concernant la r96 est resté bloqué ? Gingko From pouchintv-svn at baysse.fr Sun Oct 14 23:37:53 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Sun, 14 Oct 2007 23:37:53 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r96 - trunk Message-ID: <20071014213753.94A4F5F2E2@mail.baysse.fr> Author: gingko Date: 2007-10-14 23:37:52 +0200 (Sun, 14 Oct 2007) New Revision: 96 Added: trunk/base.cpp trunk/channels.cpp trunk/channels.h trunk/record.cpp trunk/record.h trunk/recprog.cpp trunk/recprog.h Modified: trunk/Pouchin TV.vcproj trunk/base.h trunk/epg.cpp trunk/epgfilter.cpp trunk/grabber.cpp trunk/grabber.h trunk/graph.cpp trunk/graph.h trunk/ini.cpp trunk/main.cpp trunk/main.h trunk/parse.cpp trunk/parse.h trunk/resource.h trunk/search.cpp trunk/settings.cpp trunk/settings.h trunk/trayicon.cpp Log: Ajout d'une paire de fichiers 'channels.h' et 'channels.cpp' dans lesquels sont d?\195?\169plac?\195?\169s les ?\195?\169l?\195?\169ments destin?\195?\169s ?\195?\160 la s?\195?\169lection des cha?\195?\174nes et certaines commandes li?\195?\169es. Ajout d'une paire de fichiers 'record.h' et 'record.cpp' dans lesquels sont d?\195?\169plac?\195?\169s les ?\195?\169l?\195?\169ments destin?\195?\169s ?\195?\160 effectuer les enregistrements. Ajout d'une paire de fichiers 'recprog.h' et 'recprog.cpp' dans lesquels sont d?\195?\169plac?\195?\169s les ?\195?\169l?\195?\169ments destin?\195?\169s ?\195?\160 la programmation des enregistrements ainsi qu'au lancement de ces programmations. Ajout d'un fichier 'base.cpp' dans lequel sont d?\195?\169plac?\195?\169es quelques fonctions vraiment tr?\195?\168s tr?\195?\168s tr?\195?\168s communes. La principale source du code d?\195?\169plac?\195?\169 est le fichier 'main.cpp'. L'id?\195?\169e g?\195?\169n?\195?\169rale est qu'?\195?\160 terme, ce fichier devrait tendre ?\195?\160 ne plus contenir que les ?\195?\169l?\195?\169ments de l'interface utilisateur principale. Beaucoup de factorisations faites ?\195?\160 cette occasion. Modified: trunk/Pouchin TV.vcproj =================================================================== --- trunk/Pouchin TV.vcproj 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/Pouchin TV.vcproj 2007-10-14 21:37:52 UTC (rev 96) @@ -708,6 +708,14 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + + + @@ -760,6 +768,14 @@ > + + + + @@ -786,6 +802,10 @@ > + + @@ -838,6 +858,14 @@ > + + + + Added: trunk/base.cpp =================================================================== --- trunk/base.cpp (rev 0) +++ trunk/base.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -0,0 +1,96 @@ +/* + * base.cpp + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#include "base.h" +#include "main.h" +#include "ini.h" + +#if USE_CONSOLE==1 +static HANDLE hStdOut = NULL; +#endif // #if USE_CONSOLE==1 + +#if USE_CONSOLE +void myprintf(const wchar_t *fmt, ...) +{ + wchar_t s[512]; + va_list argptr; + DWORD cnt; + + va_start(argptr, fmt); + + // Affichage conditionnel : si la chaîne de formatage débute par "%?", + // alors le premier paramètre suivant est un booléen qui conditionne + // si l'affichage a lieu ou pas. Le "%?" n'est bien sûr pas affiché. + if (fmt[0]=='%' && fmt[1]=='?') { + if (!va_arg(argptr, bool)) + return; + fmt += 2; + } + + cnt = vswprintf_s(s, _countof(s), fmt, argptr); + va_end(argptr); + +#if USE_CONSOLE==-1 + OutputDebugString(s); + // + // Les logiciels qui récupèrent les messages de debugging ont généralement + // leur propre système de capture, alors il est moins utile d'avoir + // une copie dans "pouchin.log". +#else // #if USE_CONSOLE==-1 + DWORD cCharsWritten; + + WriteConsole(hStdOut, s, cnt, &cCharsWritten, NULL); + + FILE * f; + f = fopen("pouchin.log", "a"); + if (f) { + fwprintf_s(f, s); + fclose(f); + } +#endif // #if USE_CONSOLE==-1 +} +#endif // #if USE_CONSOLE + +#if USE_CONSOLE==1 +void startConsoleWin(void) +{ + AllocConsole(); + SetConsoleTitle(L"Debug Window"); + hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); + if (consolePos.verifie()) { + HWND hConsoleWnd = GetConsoleWindow(); + MoveWindow(hConsoleWnd, consolePos.X, consolePos.Y, max(consolePos.L, 100), max(consolePos.H, 100), TRUE); + } +} +#endif //#if USE_CONSOLE==1 + + +void erreur(const wchar_t * chaine) +{ + MessageBox(hMainWnd, chaine, NULL, MB_ICONERROR); +} + Modified: trunk/base.h =================================================================== --- trunk/base.h 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/base.h 2007-10-14 21:37:52 UTC (rev 96) @@ -37,6 +37,8 @@ #endif #define WIN32_LEAN_AND_MEAN +#include + #include #include #include @@ -96,6 +98,7 @@ /////////////////////////////////////////////////////////////////// #if USE_CONSOLE void myprintf(const wchar_t *fmt, ...); +void startConsoleWin(void); #else // #if USE_CONSOLE #define myprintf(...) #endif // #if USE_CONSOLE @@ -171,104 +174,6 @@ {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} }; -enum MethodeEnregistrement { - meth_TS, // 0 - meth_PS // 1 -#if USE_RECORD_STREAM - , meth_multiplex // 2 -#endif // #if USE_RECORD_STREAM -}; - -enum ApresEnregistrement { - apr_rien, // 0 - apr_quitter, // 1 - apr_eteindrePC // 2 -}; - -enum AudioMode { - audio_1, - audio_2, - audio_AC3 -}; - -enum PlanificateurTache { - planif_sans, // 0: non planifiée - planif_avec, // 1: planifiée - planif_ajout // 2: a ajouter au planificateur lors de la validation -}; - -struct Programme { - MethodeEnregistrement methode; - AudioMode audio; - ApresEnregistrement after; - PlanificateurTache tache; - SYSTEMTIME debut; - SYSTEMTIME fin; - long chaine; - char nom[256]; - // Tableau contenant les répétitions des enregistrements - // 0: Dimanche, 1: Lundi, ...., 6: Samedi - bool repetition[7]; - bool planifie; // Indique si un timer a été lancé pour ce programme -}; - -struct Emission { - ULARGE_INTEGER debut; - char debut_str[32]; - char fin[32]; - char nom[256]; - char desc[256]; - bool latest; - SYSTEMTIME debut2; - SYSTEMTIME fin2; -}; - -struct un_son { - WORD pid; - BYTE type; - char lang[8]; -}; - -struct un_autre { - WORD pid; - char lang[8]; -}; - -struct ChainePMT { - WORD video_pid; - WORD mpeg4_pid; - WORD pcr_pid; - WORD nb_son; - un_son son[NB_MAX_PISTES]; - WORD nb_autre; - un_autre autre[NB_MAX_PISTES]; -}; - -// Définition de l'ensemble des identifiants d'une chaîne : -struct ChaineIDs { - WORD ONID; - WORD TSID; - WORD SID; - WORD numero_nit; -}; - -struct Chaine : public ChainePMT, public ChaineIDs { - char nom[64]; - char groupe[64]; - WORD canal_no; - long frequence; - WORD pmt_pid; - Emission emis[2]; -private: - HBITMAP hImage; -public: - // - // Constructeur : - Chaine() : hImage(NULL) {} - // - HBITMAP ChargeIcone(); -}; - struct Frequence { WORD canal_no; long mhz; @@ -286,3 +191,5 @@ etf_fullscreen, // plein écran (sans bordures) etf_minimized // minimisée (en icône ou pas) }; + +void erreur(const wchar_t * chaine); Added: trunk/channels.cpp =================================================================== --- trunk/channels.cpp (rev 0) +++ trunk/channels.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -0,0 +1,220 @@ +/* + * channels.cpp + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#include "base.h" +#include "channels.h" +#include "main.h" +#include "record.h" +#include "graph.h" + +std::vector Canaux; +int chaineCourante = -1; +int sonCourant = 0; +long volumeCourant = 0; + +void change_frequence(ULONG freq) +{ + HRESULT hr = pBDAControl->StartChanges(); + + myprintf(L"%?1, hr=0x%08x\n", FAILED(hr), hr); + + hr = pBDAFreq->put_Bandwidth(8); + myprintf(L"%?2, hr=0x%08x\n", FAILED(hr), hr); + + hr = pBDAFreq->put_Frequency(freq); + myprintf(L"%?3, hr=0x%08x\n", FAILED(hr), hr); + + hr = pBDAControl->CheckChanges(); + myprintf(L"%?4, hr=0x%08xn", FAILED(hr), hr); + + hr = pBDAControl->CommitChanges(); + myprintf(L"%?5, hr=0x%08x\n", FAILED(hr), hr); +} + +// S'assurer que le VMR a été initialisé : +bool do_init_vmr() +{ + if (pVMRControl == NULL) { + int res = init_vmr(); + + if (res) { + erreur(L"Erreur lors de la création du VMR"); + return false; + } + } + + return true; +} + +static void debranche_tout(IMPEG2PIDMap * pMap) +{ + IEnumPIDMap * pEnumMap; + pMap->EnumPIDMap(&pEnumMap); + + PID_MAP maps[8]; + ULONG nbPids; + pEnumMap->Next(8, maps, &nbPids); + + pEnumMap->Release(); + + for (ULONG i=0; iUnmapPID(1, &maps[i].ulPID); + myprintf(L"%?unmap foiré, hr=0x%08x\n", FAILED(hr), hr); + } +} + +void debranche() +{ // (noms de fonctions à revoir ??) + debranche_tout(pMapMPEG2); + debranche_tout(pMapSound); + debranche_tout(pMapAc3); + debranche_tout(pMapPmt); +} + +void switch_audio(int old_son, int new_son) +{ + const un_son * son_courant = Canaux[chaineCourante].son; + ULONG old_pid = son_courant[old_son].pid; + ULONG new_pid = son_courant[new_son].pid; + + int old_type = son_courant[old_son].type; + int new_type = son_courant[new_son].type; + + if (old_type==1) { + pMapAc3->UnmapPID(1, &old_pid); + } else { + pMapSound->UnmapPID(1, &old_pid); + } + + if (new_type==1) { + pMapAc3->MapPID(1, &new_pid, MEDIA_ELEMENTARY_STREAM); + } else { + pMapSound->MapPID(1, &new_pid, MEDIA_ELEMENTARY_STREAM); + } + + sonCourant=new_son; +} + +// Changement de chaîne pour la chaîne dont l'index est donné en paramètre. +// Retourne 0 si pas d'erreur, 1 si le changement n'a pas pu avoir lieu +int change_chaine(int index_chaine) +{ + bool freq_differente = true; + if (chaineCourante >= 0 && index_chaine >= 0 && + Canaux[chaineCourante].frequence == Canaux[index_chaine].frequence) + { + freq_differente = false; + } + + if (freq_differente && recording()) + return 1; // On ne change pas de fréquence si enregistrement en cours + + debranche(); + + if (index_chaine >= 0 && index_chaine<(int)Canaux.size()) + chaineCourante = index_chaine; + else + chaineCourante = -1; + + if (chaineCourante >= 0) { + const Chaine & nouveau_canal = Canaux[chaineCourante]; + + myprintf(L"zappe %i\n", chaineCourante+1); + myprintf(L"SID %i, TSID %i, ONID %i, freq : %i\n", nouveau_canal.SID, nouveau_canal.TSID, nouveau_canal.ONID, nouveau_canal.frequence); + + if (freq_differente) + change_frequence(nouveau_canal.frequence); + + ULONG pid = nouveau_canal.video_pid; + HRESULT hr; + + if (pid) { + hr = pMapMPEG2->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); + myprintf(L"%?erreur pid video, hr=0x%08x\n", FAILED(hr), hr); + } + + int piste_ac3=-1; + + for (int i=0; iMapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); + myprintf(L"%?erreur pid ac3, hr=0x%08x\n", FAILED(hr), hr); + } + } else { // passe en MPEG audio + pid = nouveau_canal.son[0].pid; + if (pid) { + hr = pMapSound->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); + sonCourant=0; + myprintf(L"%?erreur pid son, hr=0x%08x\n", FAILED(hr), hr); + } + } + + // pmt + + pid = nouveau_canal.pmt_pid; + hr = pMapPmt->MapPID(1, &pid, MEDIA_MPEG2_PSI); + myprintf(L"%?erreur pid pmt, hr=0x%08x\n", FAILED(hr), hr); + + } + return 0; +} + +void rebranche() +{ + const Chaine & canal_courant = Canaux[chaineCourante]; + HRESULT hr; + + ULONG pid = canal_courant.video_pid; + hr = pMapMPEG2->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); + myprintf(L"%?erreur pid video, hr=0x%08x\n", FAILED(hr), hr); + + pid = canal_courant.son[sonCourant].pid; + if (canal_courant.son[sonCourant].type == 1) { + hr = pMapAc3->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); + myprintf(L"%?erreur pid ac3, hr=0x%08x\n", FAILED(hr), hr); + } else { + hr = pMapSound->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); + myprintf(L"%?erreur pid son, hr=0x%08x\n", FAILED(hr), hr); + } +} + +void set_volume(long volume) +{ + IBasicAudio * pBas; + + pGraph->QueryInterface(&pBas); + pBas->put_Volume(volume); + pBas->Release(); +} Added: trunk/channels.h =================================================================== --- trunk/channels.h (rev 0) +++ trunk/channels.h 2007-10-14 21:37:52 UTC (rev 96) @@ -0,0 +1,115 @@ +/* + * channels.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#pragma once + +struct Emission { + ULARGE_INTEGER debut; + char debut_str[32]; + char fin[32]; + char nom[256]; + char desc[256]; + bool latest; + SYSTEMTIME debut2; + SYSTEMTIME fin2; +}; + +struct un_son { + WORD pid; + BYTE type; // 0 = normal, 1 = AC3 + char lang[8]; +}; + +struct un_autre { + WORD pid; + char lang[8]; +}; + +struct ChainePMT { + WORD video_pid; + WORD mpeg4_pid; + WORD pcr_pid; + WORD nb_son; + un_son son[NB_MAX_PISTES]; + WORD nb_autre; + un_autre autre[NB_MAX_PISTES]; +}; + +// Définition de l'ensemble des identifiants d'une chaîne : +struct ChaineIDs { + WORD ONID; + WORD TSID; + WORD SID; + WORD numero_nit; +}; + +struct Chaine : public ChainePMT, public ChaineIDs { + char nom[64]; + char groupe[64]; + WORD canal_no; + long frequence; + WORD pmt_pid; + Emission emis[2]; +private: + HBITMAP hImage; +public: + // + // Constructeur : + Chaine() : hImage(NULL) {} + // + HBITMAP ChargeIcone(); +}; + +// Tableau des chaînes +extern std::vector Canaux; + +extern int chaineCourante; // Index de la chaîne couramment utilisée +extern int sonCourant; // Index de la piste sonore couramment utilisée +extern long volumeCourant; // Niveau de volume sonore courant + +void change_frequence(ULONG freq); + +bool do_init_vmr(); + +// Changement de chaîne pour la chaîne dont l'index est donné en paramètre. +// Retourne 0 si pas d'erreur, 1 si le changement n'a pas pu avoir lieu +int change_chaine(int index_chaine); + +// Changement de piste son : +void switch_audio(int old_son, int new_son); + +// Changement de volume sonore : +void set_volume(long volume); + +void debranche(); +void rebranche(); + +/** + * Recherche de l'index correspondant à un numéro de chaîne 'numero_nit'. + * Retourne -1 si pas trouvé. + **/ +int trouve_chaine(WORD numero_nit); Modified: trunk/epg.cpp =================================================================== --- trunk/epg.cpp 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/epg.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -27,8 +27,9 @@ #include "base.h" #include "main.h" - #include "ini.h" +#include "recprog.h" +#include "channels.h" HWND hEpgDlg = NULL; @@ -112,179 +113,152 @@ } -INT_PTR CALLBACK EpgDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { +// Programmation d'un enregistrement : +int epg_add_programme(int canalIdx, int noemis, MethodeEnregistrement methode, AudioMode audio) +{ + const Chaine & canal = Canaux[canalIdx]; + const Emission & emis = canal.emis[noemis]; + Programme prog = { + methode, // methode + audio, // audio + apr_rien, // after + planif_sans, // tache + emis.debut2, // debut + emis.fin2, // fin + canal.numero_nit // chaine + // + // tout le reste à zéro + }; + + strcpy_s(prog.nom, _countof(prog.nom), emis.nom); + if (!prog.verifie()) + return 1; + + Programmes.insert(Programmes.begin() + Programmes.size(), prog); + sauve_programmes(); + return 0; // 0 = pas d'erreur +} + +INT_PTR CALLBACK EpgDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ switch (uMsg) { - case WM_INITDIALOG: - { - HWND hList = GetDlgItem(hDlg, IDC_LIST_EPG); + case WM_INITDIALOG: { + HWND hList = GetDlgItem(hDlg, IDC_LIST_EPG); - ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP); + ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP); - LVCOLUMN col; + LVCOLUMN col; - col.mask = LVCF_TEXT | LVCF_WIDTH; - col.pszText = L"Chaîne"; - col.cx = 90; - ListView_InsertColumn(hList, 0, &col); + col.mask = LVCF_TEXT | LVCF_WIDTH; + col.pszText = L"Chaîne"; + col.cx = 90; + ListView_InsertColumn(hList, 0, &col); - col.cx = 90; - col.pszText = L"Début"; - ListView_InsertColumn(hList, 1, &col); + col.cx = 90; + col.pszText = L"Début"; + ListView_InsertColumn(hList, 1, &col); - col.pszText = L"Fin"; - ListView_InsertColumn(hList, 2, &col); + col.pszText = L"Fin"; + ListView_InsertColumn(hList, 2, &col); - col.pszText = L"Nom du programme"; - col.cx = 220; - ListView_InsertColumn(hList, 3, &col); + col.pszText = L"Nom du programme"; + col.cx = 220; + ListView_InsertColumn(hList, 3, &col); - col.pszText = L"Description"; - col.cx = 700; - ListView_InsertColumn(hList, 4, &col); + col.pszText = L"Description"; + col.cx = 700; + ListView_InsertColumn(hList, 4, &col); - remplit_table_epg(hList); + remplit_table_epg(hList); - SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("TS")); - SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("PS")); + SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("TS")); + SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("PS")); #if USE_RECORD_STREAM - SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Multiplex")); + SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Multiplex")); #endif - SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_SETCURSEL, 0, 0); - SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Audio 1")); - SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Audio 2")); - SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Audio AC3")); - SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_SETCURSEL, 0, 0); - EnableWindow(GetDlgItem( hDlg, IDC_AUDIO_EPG), FALSE); + SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_SETCURSEL, 0, 0); + SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Audio 1")); + SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Audio 2")); + SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_ADDSTRING, 0, (LPARAM)TEXT("Audio AC3")); + SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_SETCURSEL, 0, 0); + EnableWindow(GetDlgItem( hDlg, IDC_AUDIO_EPG), FALSE); - ShowCursor(TRUE); // Suspend la disparition temporisée du curseur - return TRUE; - } + ShowCursor(TRUE); // Suspend la disparition temporisée du curseur + return TRUE; } case WM_COMMAND: switch(LOWORD(wParam)) { - case IDC_METHOD_EPG: - if (HIWORD(wParam) == CBN_SELCHANGE) { - int index = (int)SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_GETCURSEL, 0, 0); - if (index == 0 || index ==2){ - EnableWindow(GetDlgItem( hDlg, IDC_AUDIO_EPG), FALSE); - } - if (index == 1) { - EnableWindow(GetDlgItem( hDlg, IDC_AUDIO_EPG), TRUE); - } + case IDC_METHOD_EPG: + if (HIWORD(wParam) == CBN_SELCHANGE) { + int index = (int)SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_GETCURSEL, 0, 0); + if (index == 0 || index ==2){ + EnableWindow(GetDlgItem( hDlg, IDC_AUDIO_EPG), FALSE); } - return TRUE; - - case IDOK: - case IDCANCEL: - DestroyWindow(hDlg); - return TRUE; - - case IDC_UPDATE: - { - HWND hList = GetDlgItem(hDlg, IDC_LIST_EPG); - ListView_DeleteAllItems(hList); - remplit_table_epg(hList); + if (index == 1) { + EnableWindow(GetDlgItem( hDlg, IDC_AUDIO_EPG), TRUE); } - return TRUE; - case IDC_RECORD: - { - Programme prog; - LVITEMA item; - memset(&item, 0, sizeof(LVITEM)); - char buffer[127]; - item.mask = LVIF_PARAM | LVIF_TEXT; - item.iSubItem = 0; - item.iItem = (int)SendDlgItemMessage(hDlg, IDC_LIST_EPG, LVM_GETSELECTIONMARK, 0, 0); - SendDlgItemMessage(hDlg, IDC_LIST_EPG, LVM_GETITEM, 0, (LPARAM)&item); + } + return TRUE; - // (vu qu'il y a deux lignes par canal, il convient de diviser - // le numéro de ligne par deux pour obtenir les données du canal) - const Chaine & canal = Canaux[item.lParam / 2]; + case IDOK: + case IDCANCEL: + DestroyWindow(hDlg); + return TRUE; - if (item.lParam % 2 == 0) { - strcpy(prog.nom, canal.emis[0].nom); - prog.debut = canal.emis[0].debut2; - prog.fin = canal.emis[0].fin2; - } else { - strcpy(prog.nom, canal.emis[1].nom); - prog.debut = canal.emis[1].debut2; - prog.fin = canal.emis[1].fin2; - } - prog.chaine = canal.numero_nit; - prog.methode = (MethodeEnregistrement)SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_GETCURSEL, 0, 0); - prog.audio = (AudioMode)SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_GETCURSEL, 0, 0); + case IDC_UPDATE: { + HWND hList = GetDlgItem(hDlg, IDC_LIST_EPG); + ListView_DeleteAllItems(hList); + remplit_table_epg(hList); + return TRUE; } - if (DiffTime(prog.debut, prog.fin) > 0) { - erreur(L"Le programme commence après avoir fini !"); - return 1;} - if (prog.nom[0] == 0) { - erreur(L"Veuillez donner un nom à ce programme"); - return 1;} - for (int i = 0; Canaux[i].numero_nit != prog.chaine; i++) - if((UINT)i + 1 >= Canaux.size()) { - erreur(L"La chaîne est incorrecte"); - return 1;} - for (UINT i = 0; i < Programmes.size(); i++) { - const Programme & programme = Programmes[i]; - // - if(strcmp(programme.nom, prog.nom) == 0) { - erreur(L"Ce nom est déjà utilisé"); - return 1;} - if(DiffTime(programme.debut, prog.fin) <= 0 && DiffTime(programme.fin, prog.debut) >= 0) { - strcpy(buffer, "Chevauchement des horaires avec "); - strcat(buffer, programme.nom); - MessageBoxA(hMainWnd, buffer, NULL, MB_ICONERROR); - return 1;} - } + case IDC_RECORD: { + LVITEM item; + memset(&item, 0, sizeof(LVITEM)); + item.mask = LVIF_PARAM | LVIF_TEXT; + item.iSubItem = 0; + item.iItem = (int)SendDlgItemMessage(hDlg, IDC_LIST_EPG, LVM_GETSELECTIONMARK, 0, 0); + SendDlgItemMessage(hDlg, IDC_LIST_EPG, LVM_GETITEM, 0, (LPARAM)&item); - Programmes.insert(Programmes.begin() + Programmes.size(), prog); - sauve_programmes(); - } - return TRUE; + MethodeEnregistrement methode = (MethodeEnregistrement)SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_GETCURSEL, 0, 0); + AudioMode audio = (AudioMode)SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_GETCURSEL, 0, 0); + + epg_add_programme(item.lParam / 2, item.lParam % 2, methode, audio); + return TRUE; } } return FALSE; - case WM_NOTIFY: - { - LPNMITEMACTIVATE p = (LPNMITEMACTIVATE)lParam; - if (p->hdr.code == NM_DBLCLK && p->hdr.idFrom == IDC_LIST_EPG) - { - myprintf(L"double clic %i\n", p->iItem); + case WM_NOTIFY: { + LPNMITEMACTIVATE p = (LPNMITEMACTIVATE)lParam; + if (p->hdr.code == NM_DBLCLK && p->hdr.idFrom == IDC_LIST_EPG) { + myprintf(L"double clic %i\n", p->iItem); - if (p->iItem >= 0) - { - char str[256]; - LVITEMA lvi; - memset(&lvi, 0, sizeof(LVITEMA)); + if (p->iItem >= 0) { + char str[256]; + LVITEMA lvi; + memset(&lvi, 0, sizeof(LVITEMA)); - lvi.mask = LVIF_TEXT; - lvi.cchTextMax = 256; - lvi.pszText = str; - lvi.iItem = p->iItem; + lvi.mask = LVIF_TEXT; + lvi.cchTextMax = 256; + lvi.pszText = str; + lvi.iItem = p->iItem; - SendMessageA(p->hdr.hwndFrom, LVM_GETITEMTEXTA, p->iItem, (LPARAM)&lvi); + SendMessageA(p->hdr.hwndFrom, LVM_GETITEMTEXTA, p->iItem, (LPARAM)&lvi); - myprintf(L"nom %S\n", str); + myprintf(L"nom %S\n", str); - // cherche chaîne avec ce nom + // cherche chaîne avec ce nom - for(size_t i =0; i #include "base.h" Modified: trunk/grabber.h =================================================================== --- trunk/grabber.h 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/grabber.h 2007-10-14 21:37:52 UTC (rev 96) @@ -27,6 +27,8 @@ #pragma once +#include "channels.h" + class CSampleGrabber : public CUnknown, public ISampleGrabberCB // The Filter Interface { Modified: trunk/graph.cpp =================================================================== --- trunk/graph.cpp 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/graph.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -32,12 +32,16 @@ #include "base.h" +#include "graph.h" + #include "main.h" #include "search.h" #include "ini.h" +#include "record.h" + IFilterGraph2 * pGraph = NULL; IMediaControl * pControl = NULL; @@ -64,9 +68,6 @@ IBaseFilter * pNetworkTuner = NULL; IBaseFilter * pReceiverComponent = NULL; -// Tableau des enregistrements -ISampleGrabber * pSample[NB_MAX_ENREG]; - IBDA_DeviceControl * pBDAControl; IBDA_FrequencyFilter * pBDAFreq; IBDA_SignalStatistics * pStats; @@ -107,21 +108,13 @@ #endif // #if EXPORT_GRAPH - -#define free_interface(X) if (X) { X->Release(); X=NULL;} - - void clean_dshow(void) { myprintf(L"save ok\n"); // Traite tous les enregistrements en cours // Supprime la fonction de Rappel - for (int i=0; iSetCallback(NULL, 0); - } - } + stop_all_records(); myprintf(L"callback ok\n"); @@ -172,7 +165,7 @@ // Libère les interfaces d'enregistrements for (int i=0; iRelease(); - - pGrabber->QueryInterface(&pSample[i]); + enregistrements_actuels[i].query(pGrabber); filtrePrec = pGrabber; } Modified: trunk/graph.h =================================================================== --- trunk/graph.h 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/graph.h 2007-10-14 21:37:52 UTC (rev 96) @@ -27,6 +27,8 @@ #pragma once +#define free_interface(X) if (X) { X->Release(); X=NULL;} + int build_graph(void); // retourne 0 = pas d'erreur, 1 = erreur void clean_dshow(void); int init_vmr(void); @@ -59,6 +61,4 @@ extern IBaseFilter * pDemux; -extern ISampleGrabber * pSample[NB_MAX_ENREG]; - extern bool use_vmr_deinterlace; Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/ini.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -27,10 +27,11 @@ #include "base.h" #include "main.h" +#include "channels.h" #include "search.h" #include "graph.h" #include "ini.h" - +#include "recprog.h" #include "xml.h" #include @@ -359,7 +360,7 @@ pNode->getStr(L"Nom", (char*)prog.nom); - prog.chaine = pNode->getInt(L"Chaine"); + prog.chaine = (WORD)pNode->getInt(L"Chaine"); // Récupère les heures/dates de début d'enregistrement CXMLNode *enregistrements = NULL; @@ -816,7 +817,7 @@ load_config_str(ini_nom_ville, nomVille, _countof(nomVille)); exact_match = load_config_bool(ini_strict, true); - nouvelleChaine = load_config_int(ini_chaine_courante, 0); + nouvelleChaine = (WORD)load_config_int(ini_chaine_courante, 0); // CSIDL_MYVIDEO : Répertoire "Mes vidéos" (utilisé par défaut) load_config_path(ini_rep_video, video_dir, _countof(video_dir), CSIDL_MYVIDEO); Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/main.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -24,21 +24,19 @@ * a modified version of this software. * See http://pouchintv.baysse.fr/ for updates. */ -#include #include "base.h" -#include -#include - +#include "main.h" #include "ini.h" #include "settings.h" -#include "parse.h" #include "search.h" #include "trayicon.h" #include "epg.h" -#include "grabber.h" +#include "record.h" +#include "recprog.h" +#include "channels.h" #include "graph.h" #include "Hyperlinks.h" @@ -63,7 +61,6 @@ HICON hRecIcon = NULL; // Icône utilisée en mode enregistrement static HWND hStatus; static HWND hSignalDlg = NULL; -static HWND hRecordDlg = NULL; wchar_t filtreMPEG2[256]; wchar_t filtreAudio[256]; @@ -77,23 +74,7 @@ wchar_t screenshots_dir[MAX_PATH]; wchar_t video_dir[MAX_PATH]; -wchar_t mdp[256] = L""; - -static struct Enregistrement { - int chaine; // Numéro de la chaine enregistrée - ApresEnregistrement apres; // Ce que doit faire Pouchin TV Mod une fois l'enregistrement terminé - // - // Mini-constructeur : - Enregistrement() : chaine(-1), apres(apr_rien) {} -} enregistrements_actuels[NB_MAX_ENREG]; - -std::vector Canaux; -std::vector Programmes; - -int chaineCourante = -1; -int sonCourant = 0; -int nouvelleChaine = 0; -long volumeCourant = 0; +WORD nouvelleChaine = 0; wchar_t statusvol[40]; static bool muted = false; @@ -108,11 +89,6 @@ // Délai de persistance du curseur (pointeur souris) en mode plein écran : #define DUREE_CURSEUR 3000 // Valeur en millisecondes -// Délai de grâce pour l'arrêt après enregistrement : si, à l'arrêt d'un enregistrement, un -// autre enregistrement est programmé dans un délai plus court que le délai spécifié, alors -// les options d'arrêt du programme ou d'extinction de l'ordinateur sont ignorées : -#define DUREE_GRACE_QUIT 15 // Valeur en minutes - static DWORD last_zapping = 0; static DWORD last_volume_osd = 0; static DWORD last_zoom = 0; @@ -132,8 +108,6 @@ bool etirer_video = false; int zoom_ratio = 100; -int next_record = -1; - // Répertoire de Pouchin TV Mod wchar_t pouchindir_prog[MAX_PATH]; // Répertoire pour la sauvegarde des paramètres (Dossier App Data) @@ -144,80 +118,6 @@ CLcd lcd; #endif // #ifdef USE_LOGITECH_LCD -#if USE_CONSOLE==1 -static HANDLE hStdOut = NULL; -#endif // #if USE_CONSOLE==1 - -#if USE_CONSOLE -void myprintf(const wchar_t *fmt, ...) -{ - wchar_t s[512]; - va_list argptr; - DWORD cnt; - - va_start(argptr, fmt); - - // Affichage conditionnel : si la chaîne de formatage débute par "%?", - // alors le premier paramètre suivant est un booléen qui conditionne - // si l'affichage a lieu ou pas. Le "%?" n'est bien sûr pas affiché. - if (fmt[0]=='%' && fmt[1]=='?') { - if (!va_arg(argptr, bool)) - return; - fmt += 2; - } - - cnt = vswprintf_s(s, _countof(s), fmt, argptr); - va_end(argptr); - -#if USE_CONSOLE==-1 - OutputDebugString(s); - // - // Les logiciels qui récupèrent les messages de debugging ont généralement - // leur propre système de capture, alors il est moins utile d'avoir - // une copie dans "pouchin.log". -#else // #if USE_CONSOLE==-1 - DWORD cCharsWritten; - - WriteConsole(hStdOut, s, cnt, &cCharsWritten, NULL); - - FILE * f; - f = fopen("pouchin.log", "a"); - if (f) { - fwprintf_s(f, s); - fclose(f); - } -#endif // #if USE_CONSOLE==-1 -} -#endif // #if USE_CONSOLE - -#if USE_CONSOLE==1 -static void startConsoleWin(void) -{ - AllocConsole(); - SetConsoleTitle(L"Debug Window"); - hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); - if (consolePos.verifie()) { - HWND hConsoleWnd = GetConsoleWindow(); - MoveWindow(hConsoleWnd, consolePos.X, consolePos.Y, max(consolePos.L, 100), max(consolePos.H, 100), TRUE); - } -} -#endif //#if USE_CONSOLE==1 - - -void erreur(const wchar_t * chaine) -{ - MessageBox(hMainWnd, chaine, NULL, MB_ICONERROR); -} - -#define TIMER_NUMBER 123 -#define TIMER_BORDER 124 -#define TIMER_OSD 125 -#define TIMER_CURSOR 126 -#define TIMER_RECORD_START 127 -#define TIMER_RECORD_END_BASE 130 -#define TIMER_RECORD_END_FIN (TIMER_RECORD_END_BASE + NB_MAX_ENREG + 1) -#define TIMER_UPDATE (TIMER_RECORD_END_FIN + 1) - // Flag mis à TRUE si on est en mode plein écran, // ET que le curseur de la souris est temporairement visible. enum EtatCurseur { @@ -226,14 +126,6 @@ etc_fullscreen_off // Mode plein écran, éteint } etat_curseur; -long DiffTime(SYSTEMTIME time1, SYSTEMTIME time2) -{ // Fonction qui retourne la différence time1 - time2, convertie en millisecondes. - INT64 Utime1, Utime2; - SystemTimeToFileTime(&time1, (LPFILETIME)&Utime1); - SystemTimeToFileTime(&time2, (LPFILETIME)&Utime2); - return long((Utime1 - Utime2) / 10000); -} - /** * Extrait une resource de type RCData du fichier * @@ -278,79 +170,6 @@ return 1; } -/** - * Détermine si on enregistre actuellement - * - * Renvoie 1 si on enregistre actuellement, 0 sinon - **/ -bool recording(void) -{ - for (int i=0; iSetCallback(NULL, 0); - enregistrements_actuels[grab].chaine = -1; - update_record_menus(hMainWnd); -} - -/** - * Arrête tous les enregistrements - **/ -void stop_all_records(void){ - for (int i=0; iStartChanges(); - - myprintf(L"%?1, hr=0x%08x\n", FAILED(hr), hr); - - hr = pBDAFreq->put_Bandwidth(8); - myprintf(L"%?2, hr=0x%08x\n", FAILED(hr), hr); - - hr = pBDAFreq->put_Frequency(freq); - myprintf(L"%?3, hr=0x%08x\n", FAILED(hr), hr); - - hr = pBDAControl->CheckChanges(); - myprintf(L"%?4, hr=0x%08xn", FAILED(hr), hr); - - hr = pBDAControl->CommitChanges(); - myprintf(L"%?5, hr=0x%08x\n", FAILED(hr), hr); -} - -// S'assurer que le VMR a été initialisé : -bool do_init_vmr() -{ - if (pVMRControl == NULL) { - int res = init_vmr(); - - if (res) { - erreur(L"Erreur lors de la création du VMR"); - return false; - } - } - - return true; -} - -static void debranche_tout(IMPEG2PIDMap * pMap) -{ - IEnumPIDMap * pEnumMap; - pMap->EnumPIDMap(&pEnumMap); - - PID_MAP maps[8]; - ULONG nbPids; - pEnumMap->Next(8, maps, &nbPids); - - pEnumMap->Release(); - - for (ULONG i=0; iUnmapPID(1, &maps[i].ulPID); - myprintf(L"%?unmap foiré, hr=0x%08x\n", FAILED(hr), hr); - } -} - -static void debranche(void) -{ // (noms de fonctions à revoir ??) - debranche_tout(pMapMPEG2); - debranche_tout(pMapSound); - debranche_tout(pMapAc3); - debranche_tout(pMapPmt); -} - static void update_status_size(void) { RECT rect; @@ -1064,721 +804,29 @@ niData.update_tip(); } -static void switch_audio(int old_son, int new_son) +void zappe_index(int index_chaine) { - const un_son * son_courant = Canaux[chaineCourante].son; - ULONG old_pid = son_courant[old_son].pid; - ULONG new_pid = son_courant[new_son].pid; - - int old_type = son_courant[old_son].type; - int new_type = son_courant[new_son].type; - - if (old_type==1) { - pMapAc3->UnmapPID(1, &old_pid); - } else { - pMapSound->UnmapPID(1, &old_pid); - } - - if (new_type==1) { - pMapAc3->MapPID(1, &new_pid, MEDIA_ELEMENTARY_STREAM); - } else { - pMapSound->MapPID(1, &new_pid, MEDIA_ELEMENTARY_STREAM); - } - - sonCourant=new_son; - update_menus(hMainWnd, 1, update_pistes_menu); -} - -void zappe_index(int nouvelle_chaine) -{ - bool freq_differente = true; - if (chaineCourante >= 0 && nouvelle_chaine >= 0 && - Canaux[chaineCourante].frequence == Canaux[nouvelle_chaine].frequence) - { - freq_differente = false; - } - - if (freq_differente && recording()) - return; - - debranche(); - - if (nouvelle_chaine >= 0 && nouvelle_chaine<(int)Canaux.size()) - chaineCourante = nouvelle_chaine; - else - chaineCourante = -1; - - if (chaineCourante >= 0) { - const Chaine & nouveau_canal = Canaux[chaineCourante]; - - myprintf(L"zappe %i\n", chaineCourante+1); - myprintf(L"SID %i, TSID %i, ONID %i, freq : %i\n", nouveau_canal.SID, nouveau_canal.TSID, nouveau_canal.ONID, nouveau_canal.frequence); - - if (freq_differente) - change_frequence(nouveau_canal.frequence); - - ULONG pid = nouveau_canal.video_pid; - HRESULT hr; - - if (pid) { - hr = pMapMPEG2->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); - myprintf(L"%?erreur pid video, hr=0x%08x\n", FAILED(hr), hr); - } - - int piste_ac3=-1; - - for (int i=0; iMapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); - myprintf(L"%?erreur pid ac3, hr=0x%08x\n", FAILED(hr), hr); - } - } - else - { - // passe en MPEG audio - - pid = nouveau_canal.son[0].pid; - if (pid) { - hr = pMapSound->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); - sonCourant=0; - myprintf(L"%?erreur pid son, hr=0x%08x\n", FAILED(hr), hr); - } - } - - // pmt - - pid = nouveau_canal.pmt_pid; - hr = pMapPmt->MapPID(1, &pid, MEDIA_MPEG2_PSI); - myprintf(L"%?erreur pid pmt, hr=0x%08x\n", FAILED(hr), hr); - + if (change_chaine(index_chaine)==0) { update_all_menus(hMainWnd); update_status_bar(); - } + last_zapping = GetTickCount(); + set_timer_osd(); - last_zapping = GetTickCount(); - set_timer_osd(); - - // S'assurer que l'affichage initial se fait : - update_coords(); -} - -static void rebranche(void) -{ - const Chaine & canal_courant = Canaux[chaineCourante]; - HRESULT hr; - - ULONG pid = canal_courant.video_pid; - hr = pMapMPEG2->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); - myprintf(L"%?erreur pid video, hr=0x%08x\n", FAILED(hr), hr); - - pid = canal_courant.son[sonCourant].pid; - if (canal_courant.son[sonCourant].type == 1) { - hr = pMapAc3->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); - myprintf(L"%?erreur pid ac3, hr=0x%08x\n", FAILED(hr), hr); - } else { - hr = pMapSound->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); - myprintf(L"%?erreur pid son, hr=0x%08x\n", FAILED(hr), hr); + // S'assurer que l'affichage initial se fait : + update_coords(); } } -void zappe_chaine(int nouvelle_chaine) +void zappe_chaine(WORD numero_chaine) { // cherche l'index de la chaîne voulue - int trouve = -1; + int index_chaine = trouve_chaine(numero_chaine); - for (size_t i=0; trouve == -1 && iDelete(pwszTaskName); - // Crée la nouvelle tâche - hr = pITS->NewWorkItem(pwszTaskName, CLSID_CTask, IID_ITask, (IUnknown**)&pTask); - - pITS->Release(); - - wchar_t path[MAX_PATH]; - - // Définition de la tâche - GetModuleFileName(NULL, path, _countof(path)); - pTask->SetApplicationName(path); - pTask->SetParameters(L"-minimize"); - GetCurrentDirectory(_countof(path), path); - pTask->SetWorkingDirectory(path); - hr=pTask->SetAccountInformation(username, mdp); - pTask->SetFlags(TASK_FLAG_DELETE_WHEN_DONE | TASK_FLAG_SYSTEM_REQUIRED); - pTask->SetMaxRunTime(INFINITE); - pTask->CreateTrigger(&piNewTrigger, &pTaskTrigger); - - ZeroMemory(&Trig, sizeof(TASK_TRIGGER)); - Trig.cbTriggerSize = sizeof(TASK_TRIGGER); - Trig.wBeginDay = date.wDay; - Trig.wBeginMonth = date.wMonth; - Trig.wBeginYear = date.wYear; - Trig.wStartHour = date.wHour; - Trig.wStartMinute = date.wMinute; - - bool repetition = false; - for (int i=0; i<7; i++) - if (prog.repetition[i]) { - repetition = true; - break; - } - - if (repetition) { - // On a demandé à ce que la tâche soit répétée - Trig.TriggerType = TASK_TIME_TRIGGER_WEEKLY; - - WEEKLY jours; - jours.WeeksInterval = 1; // Répète toutes les semaines - jours.rgfDaysOfTheWeek = 0; - - if (prog.repetition[1]) - jours.rgfDaysOfTheWeek += TASK_MONDAY; - if (prog.repetition[2]) - jours.rgfDaysOfTheWeek += TASK_TUESDAY; - if (prog.repetition[3]) - jours.rgfDaysOfTheWeek += TASK_WEDNESDAY; - if (prog.repetition[4]) - jours.rgfDaysOfTheWeek += TASK_THURSDAY; - if (prog.repetition[5]) - jours.rgfDaysOfTheWeek += TASK_FRIDAY; - if (prog.repetition[6]) - jours.rgfDaysOfTheWeek += TASK_SATURDAY; - if (prog.repetition[0]) - jours.rgfDaysOfTheWeek += TASK_SUNDAY; - - Trig.Type.Weekly = jours; - } else { - // Pas de répétition de la tâche - Trig.TriggerType = TASK_TIME_TRIGGER_ONCE; - } - - pTaskTrigger->SetTrigger(&Trig); - - pTask->QueryInterface(IID_IPersistFile, (void **)&pPersistFile); - pPersistFile->Save(NULL, TRUE); - pPersistFile->Release(); - - pTaskTrigger->Release(); - pTask->Release(); - - prog.tache = planif_avec; - } - } - // On efface le mot de passe (inutile maintenant que tous les programmes sont sauvegardés) - SecureZeroMemory(mdp, sizeof(mdp)); - wcscpy(mdp, L""); - } - - return 0; -} - -static int supprimer_taches(std::vector &taches_supprimer) { - for (size_t i=0; iDelete(pwszTaskName); - - pITS->Release(); - } - - taches_supprimer.clear(); - - return 0; -} - -/** - * On passe un numéro de chaine en paramètre, - * et on retourne la fréquence du multiplex correspondant - **/ -long getFrequence(long chaine){ - for (size_t i=0; i&taches_supprimer) -{ - char buffer[127]; - int index; - memset(buffer, 0, 127); - SYSTEMTIME time_buffer; - - Programme prog; - ZeroMemory(&prog, sizeof(Programme)); - - buffer[0] = 127; - SendDlgItemMessage(hwndDlg, IDC_NAME, EM_GETLINE, 0, (LPARAM)buffer); - for(int i = 1; buffer[2 * (i - 1)] != 0; i++) - buffer[i] = buffer[2 * i]; - strcpy(prog.nom, buffer); - - index = (int)SendDlgItemMessage(hwndDlg, IDC_CHANNEL, CB_GETCURSEL, 0, 0); - prog.chaine = Canaux[index].numero_nit; - - SendDlgItemMessage(hwndDlg, IDC_DATE_START, DTM_GETSYSTEMTIME, 0, (LPARAM)&time_buffer); - prog.debut = time_buffer; - SendDlgItemMessage(hwndDlg, IDC_TIME_START, DTM_GETSYSTEMTIME, 0, (LPARAM)&time_buffer); - prog.debut.wHour = time_buffer.wHour; - prog.debut.wMinute = time_buffer.wMinute; - prog.debut.wSecond = time_buffer.wSecond; - prog.debut.wMilliseconds = 0; - - SendDlgItemMessage(hwndDlg, IDC_DATE_END, DTM_GETSYSTEMTIME, 0, (LPARAM)&time_buffer); - prog.fin = time_buffer; - SendDlgItemMessage(hwndDlg, IDC_TIME_END, DTM_GETSYSTEMTIME, 0, (LPARAM)&time_buffer); - prog.fin.wHour = time_buffer.wHour; - prog.fin.wMinute = time_buffer.wMinute; - prog.fin.wSecond = time_buffer.wSecond; - prog.fin.wMilliseconds = 0; - - prog.methode = (MethodeEnregistrement)SendDlgItemMessage(hwndDlg, IDC_METHOD, CB_GETCURSEL, 0, 0); - prog.audio = (AudioMode)SendDlgItemMessage(hwndDlg, IDC_AUDIO, CB_GETCURSEL, 0, 0); - - if(IsDlgButtonChecked(hwndDlg, IDC_AFTER_POWEROFF) == BST_CHECKED) { - prog.after = apr_eteindrePC; - } else if(IsDlgButtonChecked(hwndDlg, IDC_AFTER) == BST_CHECKED) { - prog.after = apr_quitter; - } else { - prog.after = apr_rien; - } - - SYSTEMTIME time; - GetLocalTime(&time); - - if(DiffTime(prog.debut, time) < 0) { - erreur(L"L'heure de commencement du programme est dépassée !"); - return 1;} - if(DiffTime(prog.debut, prog.fin) > 0) { - erreur(L"Le programme commence après avoir fini !"); - return 1;} - if(prog.nom[0] == 0) { - erreur(L"Veuillez donner un nom à ce programme"); - return 1;} - for(int i = 0; Canaux[i].numero_nit != prog.chaine; i++) - if((UINT)i + 1 >= Canaux.size()) { - erreur(L"La chaîne est incorrecte"); - return 1;} - for(UINT i = 0; i < Programmes.size(); i++) { - if(strcmp(Programmes[i].nom, prog.nom) == 0) { - erreur(L"Ce nom est déjà utilisé"); - return 1; - } - // Vérifie que le programme est sur le même multiplex - if(DiffTime(Programmes[i].debut, prog.fin) <= 0 - && DiffTime(Programmes[i].fin, prog.debut) >= 0 - && getFrequence(Programmes[i].chaine) != Canaux[index].frequence) { - wchar_t messageErreur[1024]; - swprintf_s(messageErreur, _countof(messageErreur), L"Chevauchement des horaires avec \"%S\", qui ne partage pas le même multiplex!", Programmes[i].nom); - erreur(messageErreur); - return 1; - } - } - - // Ajoute l'indicatif pour la répétition - if (IsDlgButtonChecked(hwndDlg, IDC_REP_LUNDI) == BST_CHECKED) - prog.repetition[1] = true; - - if (IsDlgButtonChecked(hwndDlg, IDC_REP_MARDI) == BST_CHECKED) - prog.repetition[2] = true; - - if (IsDlgButtonChecked(hwndDlg, IDC_REP_MERCREDI) == BST_CHECKED) - prog.repetition[3] = true; - - if (IsDlgButtonChecked(hwndDlg, IDC_REP_JEUDI) == BST_CHECKED) - prog.repetition[4] = true; - - if (IsDlgButtonChecked(hwndDlg, IDC_REP_VENDREDI) == BST_CHECKED) - prog.repetition[5] = true; - - if (IsDlgButtonChecked(hwndDlg, IDC_REP_SAMEDI) == BST_CHECKED) - prog.repetition[6] = true; - - if (IsDlgButtonChecked(hwndDlg, IDC_REP_DIMANCHE) == BST_CHECKED) - prog.repetition[0] = true; - - if (IsDlgButtonChecked(hwndDlg, IDC_TACHE) == BST_CHECKED) { - prog.tache = planif_ajout; - } else { - prog.tache = planif_sans; - } - - // On recherche la tâche que l'on a modifiée, pour la supprimer en premier - size_t i; - for (i=0; i taches_supprimer; - - for(int i = 0; i < n; i++) { - if(SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_GETITEMSTATE, i, LVIS_SELECTED) & LVIS_SELECTED) - sel = i; - } - - switch (uMsg) { - - case WM_INITDIALOG: { - - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); - - LVCOLUMN colonne; - memset(&colonne, 0, sizeof(LVCOLUMN)); - - colonne.mask = LVCF_TEXT|LVCF_WIDTH; - - colonne.cx = 100; - colonne.pszText = L"Nom"; - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 0, (LPARAM)&colonne); - - colonne.cx = 50; - colonne.pszText = L"Chaîne"; - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 1, (LPARAM)&colonne); - - colonne.cx = 140; - colonne.pszText = L"Début"; - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 2, (LPARAM)&colonne); - - colonne.cx = 140; - colonne.pszText = L"Fin"; - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 3, (LPARAM)&colonne); - - remplit_liste_programmes(hwndDlg, IDC_LIST_PROGRAMMES); - - SYSTEMTIME time; - - GetLocalTime(&time); - - time.wSecond = 0; - time.wMilliseconds = 0; - SendDlgItemMessage(hwndDlg, IDC_TIME_START, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&time); - SendDlgItemMessage(hwndDlg, IDC_TIME_END, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&time); - - for (size_t i=0; i= 0 && ((LPNMHDR)lParam)->code == NM_CLICK) { - const Programme & prog = Programmes[sel]; - int index = -1; - - SendDlgItemMessageA(hwndDlg, IDC_NAME, WM_SETTEXT, 0, (LPARAM)prog.nom); - - for (size_t i=0; index == -1 && iQueryInterface(&pBas); - pBas->put_Volume(volume); - pBas->Release(); -} - static int InitDshow(void) // retourne 0 = pas d'erreur, 1 = erreur { int result = build_graph(); @@ -2144,7 +1183,9 @@ static void traite_numero(int nb) { - nouvelleChaine = nouvelleChaine * 10 + nb; + nouvelleChaine = (nouvelleChaine * 10 + (WORD)nb) % 1000; + // (modulo 1000 au cas où il y aurait trop de chiffres) + SetTimer(hMainWnd, TIMER_NUMBER, 1000, NULL); last_chaine = GetTickCount(); @@ -2304,14 +1345,9 @@ #ifdef USE_LOGITECH_LCD lcd.Mute(muted); #endif // #ifdef USE_LOGITECH_LCD - long vol = muted ? -8000 : (volumeCourant < 0 ? volumeCourant : 0) ; - IBasicAudio * pBas; + set_volume(muted ? -8000 : (volumeCourant < 0 ? volumeCourant : 0)); - pGraph->QueryInterface(&pBas); - pBas->put_Volume(vol); - pBas->Release(); - if (!is_vista) { RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } @@ -2321,22 +1357,13 @@ static void update_volume(bool augmente) { if (augmente && volumeCourant < 0) - { volumeCourant += 80; - } else if (!augmente && volumeCourant > -8000) - { + else if (!augmente && volumeCourant > -8000) volumeCourant -= 80; - } if (!muted) - { - IBasicAudio * pBas; + set_volume(volumeCourant); - pGraph->QueryInterface(&pBas); - pBas->put_Volume(volumeCourant); - pBas->Release(); - } - #ifdef USE_LOGITECH_LCD lcd.SetVolume(volumeCourant); #endif // #ifdef USE_LOGITECH_LCD @@ -2401,20 +1428,10 @@ zappe_chaine(nouvelleChaine); } else { // trouver l'index de la chaîne + int index_chaine = trouve_chaine(nouvelleChaine); - int num_chaine = (int)Canaux.size(); - - int index_chaine = -1; - - for (int i=0; i= 0 && Canaux[index_chaine].frequence == Canaux[chaineCourante].frequence) { + if (index_chaine >= 0 && Canaux[index_chaine].frequence == Canaux[chaineCourante].frequence) zappe_index(index_chaine); - } } nouvelleChaine = 0; } @@ -2447,38 +1464,6 @@ } } -// Arrêt de l'ordinateur : -static bool shutdown() -{ - HANDLE hToken; - TOKEN_PRIVILEGES tkp; - - // Récupère un jetton pour l'application. - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) - return false; - - // Obtient le LUID pour le privilège d'arrêt. - LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); - - tkp.PrivilegeCount = 1; // 1 privilège à obtenir - tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - - // Obtient le privilège d'arrêt pour ce processus. - AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); - - if (GetLastError() != ERROR_SUCCESS) - return false; - - // Arrête Windows, et force toutes les applications à s'arrêter. - if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | - SHTDN_REASON_MINOR_UPGRADE |SHTDN_REASON_FLAG_PLANNED)) - // Erreur, on annule tout - return false; - - // Tout est OK, le système s'arrête... - return true; -} - // Traitement de la mise à jour par Internet : static void do_web_update() { @@ -2621,199 +1606,6 @@ } } -// Traitement des démarrages d'enregistrements : -static void do_record_start(int grab) -{ - Programme & prog = Programmes[next_record]; // Description de l'enregistrement à effectuer - int index = -1; - - for (size_t i=0; index == -1 && i=0) { - const Chaine & canal_enregistre = Canaux[index]; - // - if (canal_enregistre.frequence == Canaux[chaineCourante].frequence || !recording()) { - - if (canal_enregistre.frequence != Canaux[chaineCourante].frequence) { - change_frequence(canal_enregistre.frequence); - chaineCourante = index; - sonCourant = 0; - } - - if (!IsMinimized(hMainWnd) && suspend_minimized) - rebranche(); - - ISampleGrabberCB * pCallback = NULL; - int video; - int son; - int index_son = -1; - - SYSTEMTIME st; - GetLocalTime(&st); - - for(int i=0; (index_son == -1) && iSetCallback(pCallback, 0); - enregistrements_actuels[grab].chaine = index; - - // On mémorise ce qu'il faut faire à la fin de l'enregistrement programmé - enregistrements_actuels[grab].apres = prog.after; - - update_record_menus(hMainWnd); - - // Vérif si l'heure de début est déjà passée - SYSTEMTIME localtime; - GetLocalTime(&localtime); - if (DiffTime(prog.debut, localtime) < 0) - SetTimer(hMainWnd, TIMER_RECORD_END_BASE+grab, DiffTime(prog.fin, localtime), NULL); - else - SetTimer(hMainWnd, TIMER_RECORD_END_BASE+grab, DiffTime(prog.fin, prog.debut), NULL); - - // Recherche si l'enregistrement doit être répété - bool repetition = false; - for (int i=0; i<7; i++) - if (prog.repetition[i]) { - repetition = true; - break; - } - - if (repetition){ - // Recherche de la prochaine date - int recherche; - - for (recherche=prog.debut.wDayOfWeek+1; recherche<7; recherche++) - if (prog.repetition[recherche]) - break; - - if (recherche == 7) - for (recherche=0; recherche=0) -} - -static void do_record_stop(int grab) -{ - if (enregistrements_actuels[grab].chaine != -1) { - stop_record(grab); - } - - long diff; - SYSTEMTIME time; - GetLocalTime(&time); - - // Calcul du temps restant avant le prochain début d'enregistrement - if (next_record != -1) { - diff = DiffTime(Programmes[next_record].debut, time); - } else { - diff =-1; // ... enfin, seulement s'il y en a un ... - } - myprintf(L"diff : %i mS\n", diff); - - if (!recording() && (diff >= DUREE_GRACE_QUIT*60*1000 || diff == -1)) { - // On entre ici si aucun (autre) enregistrement n'est en cours, et si aucun - // enregistrement n'est programmé pour débuter dans un délai défini par - // la constante DUREE_GRACE_QUIT. - - ApresEnregistrement after = enregistrements_actuels[grab].apres; - - // Arrêt de pouchinTV ? - if (after == apr_quitter) { - if (IsMinimized(hMainWnd)) - ShowWindow(hMainWnd, SW_RESTORE); - DestroyWindow(hMainWnd); - } - // Arrêt de l'ordinateur - if (after == apr_eteindrePC) { - if (!shutdown()) { - erreur(L"Impossible d'arrêter l'ordinateur"); - } - } - } -} - static void do_osd(HDC hdc) { if (chaineCourante >= 0) { @@ -3016,73 +1808,6 @@ } } -static void do_record_ts() -{ - int grab = getGrabber(); - if (grab>=0) { - const Chaine & canal_courant = Canaux[chaineCourante]; - NomFichierAvecDate nom_fichier(video_dir, canal_courant.nom, "ts"); - int video = canal_courant.video_pid ? canal_courant.video_pid : canal_courant.mpeg4_pid; - - ISampleGrabberCB * pCallback = - new CSampleGrabber( - nom_fichier.Create(), - canal_courant.pmt_pid, - video, - canal_courant.son, - canal_courant.nb_son, - canal_courant.autre, - canal_courant.nb_autre); - - enregistrements_actuels[grab].chaine = chaineCourante; - enregistrements_actuels[grab].apres = apr_rien; - pSample[grab]->SetCallback(pCallback, 0); - - update_record_menus(hMainWnd); - } -} - -static void do_record_ps() -{ - int grab = getGrabber(); - if (grab>=0) { - const Chaine & canal_courant = Canaux[chaineCourante]; - NomFichierAvecDate nom_fichier(video_dir, canal_courant.nom, "mpg"); - int video = canal_courant.video_pid ? canal_courant.video_pid : canal_courant.mpeg4_pid; - int son = canal_courant.son[sonCourant].pid; - - ISampleGrabberCB * pCallback = - new CSampleGrabber( - nom_fichier.Create(), - video, - son); - - enregistrements_actuels[grab].chaine = chaineCourante; - enregistrements_actuels[grab].apres = apr_rien; - pSample[grab]->SetCallback(pCallback, 0); - - update_record_menus(hMainWnd); - } -} - -#if USE_RECORD_STREAM -static void do_record_stream() -{ - int grab; - - if (!recording() && (grab = getGrabber())>=0) { - NomFichierAvecDate nom_fichier(video_dir, "Transport Stream", "ts"); - - ISampleGrabberCB * pCallback = new CSampleGrabber(nom_fichier.Create()); - - pSample[grab]->SetCallback(pCallback, 0); - - update_menu_recording(hMainWnd); - update_chaines_menu(hMainWnd); - } -} -#endif // #if USE_RECORD_STREAM - static void do_command(WORD wID) { int grab; @@ -3123,13 +1848,7 @@ break; case IDM_DELAYED_RECORD: - if (hRecordDlg) - BringWindowToTop(hRecordDlg); - else { - hRecordDlg = CreateDialog(hAppInstance, - MAKEINTRESOURCE(IDD_DELAYED_RECORD), hMainWnd, RecordDialogProc); - ShowWindow(hRecordDlg, SW_SHOW); - } + open_record_dialog(); break; case IDM_MPEG2: @@ -3215,23 +1934,28 @@ break; case IDM_RECORD_CHANNEL_TS: - do_record_ts(); + if (start_record_ts(chaineCourante)>=0) + update_record_menus(hMainWnd); break; case IDM_RECORD_CHANNEL_PS: - do_record_ps(); + if (start_record_ps(chaineCourante, sonCourant)>=0) + update_record_menus(hMainWnd); break; #if USE_RECORD_STREAM case IDM_RECORD_STREAM: - do_record_stream(); + if (start_record_stream()>=0) + update_record_menus(hMainWnd); break; #endif // #if USE_RECORD_STREAM case IDM_STOP_RECORD: grab = getGrabberChaine(chaineCourante); - if (grab>=0) + if (grab>=0) { stop_record(grab); + update_record_menus(hMainWnd); + } break; case IDM_DELAYED_STOP: @@ -3346,6 +2070,7 @@ } else if (wID>=500 && wID<600) { // cas changement piste switch_audio(sonCourant, wID-500); + update_menus(hMainWnd, 1, update_pistes_menu); } } } @@ -3411,19 +2136,18 @@ // Gestion du timer de début d'enregistrement : KillTimer(hMainWnd, TIMER_RECORD_START); - grab = getGrabber(); - if (grab == -1) { - set_timer_record(); - break; - } + if (do_record_start()>=0) + update_record_menus(hMainWnd); - do_record_start(grab); + // Redemande le calcul du prochain enregistrement + set_timer_record(); break; default: grab = (int)(wTimerID-TIMER_RECORD_END_BASE); if (grab >= 0 && grab < NB_MAX_ENREG) { // Gestion du timer de fin d'enregistrement : do_record_stop(grab); + update_record_menus(hMainWnd); } } } @@ -3865,21 +2589,9 @@ // Comme marqué, on crée la barre de status de la fenêtre create_status_bar(); - // Charge la liste des programmes - lit_programmes(); + // Chargement et purge de la liste des programmes + init_programmation(); - SYSTEMTIME time; - GetLocalTime(&time); - for(UINT i = 0; i < Programmes.size(); i++) { - // On garde les programmes, même si l'heure de début est passée - if (DiffTime(Programmes[i].fin, time) < 0) - // On efface les programmes dont l'heure de fin est passée - Programmes.erase(Programmes.begin()+i); - } - - // Sauvegarde à nouveau la liste des programmes - sauve_programmes(); - set_timer_record(); // Récupère la version de windows @@ -4007,7 +2719,7 @@ continue; if (hEpgDlg!=NULL && IsDialogMessage(hEpgDlg, &msg)) continue; - if (hRecordDlg!=NULL && IsDialogMessage(hRecordDlg, &msg)) + if (is_record_dialog_message(msg)) continue; if (TranslateAccelerator(hWnd, hAccel, &msg)) continue; Modified: trunk/main.h =================================================================== --- trunk/main.h 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/main.h 2007-10-14 21:37:52 UTC (rev 96) @@ -31,12 +31,8 @@ extern wchar_t szAppName[]; extern std::vector freq_scan; -extern std::vector Canaux; -extern std::vector Programmes; -extern int nouvelleChaine; -extern int chaineCourante; -extern long volumeCourant; +extern WORD nouvelleChaine; extern HINSTANCE hAppInstance; extern HWND hMainWnd; @@ -46,16 +42,9 @@ DWORD get_priority(); -void change_frequence(ULONG freq); +void zappe_index(int index_chaine); +void zappe_chaine(WORD numero_chaine); -bool do_init_vmr(); -void zappe_index(int nouvelle_chaine); -void zappe_chaine(int nouvelle_chaine); -bool recording(void); -void erreur(const wchar_t * chaine); - -long DiffTime(SYSTEMTIME time1, SYSTEMTIME time2); - extern wchar_t filtreMPEG2[256]; extern wchar_t filtreAudio[256]; extern wchar_t filtreAc3[256]; @@ -93,3 +82,13 @@ #if LOG_DSHOW extern HANDLE logFile; #endif // #if LOG_DSHOW + +// Liste des codes de timers définis : +#define TIMER_NUMBER 123 +#define TIMER_BORDER 124 +#define TIMER_OSD 125 +#define TIMER_CURSOR 126 +#define TIMER_RECORD_START 127 +#define TIMER_RECORD_END_BASE 130 +#define TIMER_RECORD_END_FIN (TIMER_RECORD_END_BASE + NB_MAX_ENREG + 1) +#define TIMER_UPDATE (TIMER_RECORD_END_FIN + 1) Modified: trunk/parse.cpp =================================================================== --- trunk/parse.cpp 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/parse.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -26,6 +26,7 @@ */ #include "base.h" #include "main.h" +#include "channels.h" #include "graph.h" #include "ini.h" Modified: trunk/parse.h =================================================================== --- trunk/parse.h 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/parse.h 2007-10-14 21:37:52 UTC (rev 96) @@ -27,6 +27,8 @@ #pragma once +#include "channels.h" + struct PMT; void parse_pmt(const PMT * ppmt, int max, ChainePMT & pmt/*, bool debug*/); Added: trunk/record.cpp =================================================================== --- trunk/record.cpp (rev 0) +++ trunk/record.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -0,0 +1,223 @@ +/* + * record.cpp + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#include "record.h" +#include "main.h" +#include "graph.h" +#include "channels.h" +#include "ini.h" +#include "grabber.h" + +Enregistrement enregistrements_actuels[NB_MAX_ENREG]; + +void Enregistrement::start(int index_chaine, ISampleGrabberCB * pCallback, ApresEnregistrement apr) +{ + stop(); // précaution + if (pSample && pCallback && index_chaine!=-1) { + pSample->SetCallback(pCallback, 0); + chaine = index_chaine; + apres = apr; + } +} + +ApresEnregistrement Enregistrement::stop() +{ + ApresEnregistrement apr = apres; + + if (pSample && chaine!=-1) + pSample->SetCallback(NULL, 0); + chaine = -1; + apres = apr_rien; + return apr; +} + +void Enregistrement::query(IBaseFilter * pGrabber) +{ + if (pSample==NULL) + pGrabber->QueryInterface(&pSample); +} + +void Enregistrement::free() +{ + free_interface(pSample); +} + +/** + * Détermine si on enregistre actuellement + * + * Renvoie 1 si on enregistre actuellement, 0 sinon + **/ +bool recording() +{ + for (int i=0; i=0) { + const Chaine & canal = Canaux[index_chaine]; + NomFichierAvecDate nom_fichier(video_dir, canal.nom, "ts"); + int video = canal.video_pid ? canal.video_pid : canal.mpeg4_pid; + + ISampleGrabberCB * pCallback = + new CSampleGrabber( + nom_fichier.Create(), + canal.pmt_pid, + video, + canal.son, + canal.nb_son, + canal.autre, + canal.nb_autre); + + enregistrements_actuels[grab].start(index_chaine, pCallback); + } + return grab; +} + +// Démarrage d'un enregistrement en mode PS, pour la chaîne dont l'index +// est égal à 'index_chaine', avec 'index_son' comme piste son +// Le tuner est supposé être déjà syntonisé sur la bonne fréquence +// Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. +// TODO : retirer la restriction sur la syntonisation +// TODO : faire en sorte que toutes les pistes son soient enregistrées si 'index_son'=-1 +int start_record_ps(int index_chaine, int index_son) +{ + int grab = getFreeGrabber(); + if (grab>=0) { + const Chaine & canal = Canaux[index_chaine]; + NomFichierAvecDate nom_fichier(video_dir, canal.nom, "mpg"); + int video = canal.video_pid ? canal.video_pid : canal.mpeg4_pid; + int son = canal.son[index_son].pid; + + ISampleGrabberCB * pCallback = + new CSampleGrabber( + nom_fichier.Create(), + video, + son); + + enregistrements_actuels[grab].start(index_chaine, pCallback); + } + return grab; +} + +#if USE_RECORD_STREAM +// Démarrage d'un enregistrement global du multiplex. +// Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. +// TODO : ajouter un paramètre (par ex. index_chaine) pour que soit préalablement syntonisé le multiplex +// correspondant à la chaîne désignée. +int start_record_stream() +{ + int grab = -1; + + if (!recording() && (grab = getFreeGrabber())>=0) { + NomFichierAvecDate nom_fichier(video_dir, "Transport Stream", "ts"); + + ISampleGrabberCB * pCallback = new CSampleGrabber(nom_fichier.Create()); + + enregistrements_actuels[grab].start(-2, pCallback); + } + return grab; +} +#endif // #if USE_RECORD_STREAM Added: trunk/record.h =================================================================== --- trunk/record.h (rev 0) +++ trunk/record.h 2007-10-14 21:37:52 UTC (rev 96) @@ -0,0 +1,101 @@ +/* + * recprog.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#pragma once + +#include "recprog.h" + +class Enregistrement { + int chaine; // Numéro de la chaine enregistrée + ApresEnregistrement apres; // Ce que doit faire Pouchin TV Mod une fois l'enregistrement terminé + ISampleGrabber * pSample; +public: + // + // Mini-constructeur : + Enregistrement() : chaine(-1), apres(apr_rien), pSample(NULL) {} + // + bool recording() const {return chaine >=0 ;} + bool isChannel(int index_chaine) const {return chaine == index_chaine;} + void start(int index_chaine, ISampleGrabberCB * pCallback, ApresEnregistrement apr = apr_rien); + void query(IBaseFilter * pGrabber); + void free(); + void setAfter(ApresEnregistrement apr) {apres = apr;} + ApresEnregistrement stop(); +}; + +extern Enregistrement enregistrements_actuels[NB_MAX_ENREG]; + +// Fonction retournant 'true' s'il y a au moins un enregistrement en cours +bool recording(); + +/** + * Arrêt de l'enregistrement d'index 'grab'. Retourne le code correspondant + * à l'action qui avait été programmée à l'issue de cet enregistrement. + **/ +ApresEnregistrement stop_record(int grab); + +/** + * Arrêt de tous les enregistrements en cours + **/ +void stop_all_records(); + +/** + * Chercher l'index des informations concernant la chaine de numéro 'chaine' si celle-ci est + * en cours d'enregistrement. Retourne -1 si elle ne l'est pas. + **/ +int getGrabberChaine(int chaine); + +/** + * Chercher un poste d'enregistrement libre. Retourne l'index de ce poste, ou bien + * -1 s'il n'y en a plus de disponible. + **/ +int getFreeGrabber(); + +// Démarrage d'un enregistrement en mode TS, pour la chaîne dont l'index est égal à index_chaine +// Le tuner est supposé être déjà syntonisé sur la bonne fréquence +// Toutes les pistes audio sont enregistrées +// Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. +// TODO : retirer la restriction sur la syntonisation +// TODO : ajouter le paramètre 'index_son' pour choisir entre l'enregistrement d'une piste audio donnée, +// ou bien toutes les pistes audio si -1 +int start_record_ts(int index_chaine); + +// Démarrage d'un enregistrement en mode PS, pour la chaîne dont l'index +// est égal à 'index_chaine', avec 'index_son' comme piste son +// Le tuner est supposé être déjà syntonisé sur la bonne fréquence +// Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. +// TODO : retirer la restriction sur la syntonisation +// TODO : faire en sorte que toutes les pistes son soient enregistrées si 'index_son'=-1 +int start_record_ps(int index_chaine, int index_son); + +#if USE_RECORD_STREAM +// Démarrage d'un enregistrement global du multiplex. +// Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. +// TODO : ajouter un paramètre (par ex. index_chaine) pour que soit préalablement syntonisé le multiplex +// correspondant à la chaîne désignée. +int start_record_stream(); +#endif Added: trunk/recprog.cpp =================================================================== --- trunk/recprog.cpp (rev 0) +++ trunk/recprog.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -0,0 +1,923 @@ +/* + * recprog.cpp + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#include "recprog.h" +#include "base.h" +#include "channels.h" +#include "record.h" +#include "main.h" +#include "ini.h" +// +#include +#include + +// Délai de grâce pour l'arrêt après enregistrement : si, à l'arrêt d'un enregistrement, un +// autre enregistrement est programmé dans un délai plus court que le délai spécifié, alors +// les options d'arrêt du programme ou d'extinction de l'ordinateur sont ignorées : +#define DUREE_GRACE_QUIT 15 // Valeur en minutes + +std::vector Programmes; +int next_record = -1; + +static HWND hRecordDlg = NULL; +static wchar_t mdp[256] = L""; + +/** + * On passe un numéro de chaine en paramètre, + * et on retourne la fréquence du multiplex correspondant + **/ +static long getFrequence(WORD chaine) +{ + int index_chaine = trouve_chaine(chaine); + + if (index_chaine >= 0) + return Canaux[index_chaine].frequence; + + return -1; +} + +/** + * Fonction qui retourne la différence time1 - time2, convertie en millisecondes. + **/ +static long DiffTime(SYSTEMTIME time1, SYSTEMTIME time2) +{ + INT64 Utime1, Utime2; + SystemTimeToFileTime(&time1, (LPFILETIME)&Utime1); + SystemTimeToFileTime(&time2, (LPFILETIME)&Utime2); + return long((Utime1 - Utime2) / 10000); +} + +/** + * Vérification de la validité de la programmation 'prog' + * Retourne true si ok, false si erreur. + **/ +bool Programme::verifie() const +{ + int index = trouve_chaine(chaine); + SYSTEMTIME time; + wchar_t buffer[256]; + + if (index<0) { + erreur(L"La chaîne est incorrecte"); + return false; + } + + GetLocalTime(&time); + + if (DiffTime(debut, time) < 0) { + erreur(L"L'heure de commencement du programme est dépassée !"); + return false; + } + + if (DiffTime(debut, fin) > 0) { + erreur(L"Le programme commence après avoir fini !"); + return false; + } + + if (nom[0] == 0) { + erreur(L"Veuillez donner un nom à ce programme"); + return false; + } + + for(UINT i = 0; i < Programmes.size(); i++) { + const Programme & prog_verif = Programmes[i]; + + if(strcmp(prog_verif.nom, nom) == 0) { + erreur(L"Ce nom est déjà utilisé"); + return false; + } + // S'il y a chevauchement des horaires, vérifie que le programme est sur le même multiplex : + if (DiffTime(prog_verif.debut, fin) <= 0 && + DiffTime(prog_verif.fin, debut) >= 0 && + getFrequence(prog_verif.chaine) != Canaux[index].frequence + ) { + swprintf_s(buffer, _countof(buffer), + L"Chevauchement des horaires avec \"%S\", qui ne partage pas le même multiplex !", + prog_verif.nom); + erreur(buffer); + return false; + } + } + + return true; // pas d'erreur +} + +/** + * Traitement du chargement de la liste des programmes au démarrage, et purge + * des enregistrements périmés : + **/ +void init_programmation() +{ + // Charge la liste des programmes + lit_programmes(); + + SYSTEMTIME time; + GetLocalTime(&time); + for(UINT i = 0; i < Programmes.size(); i++) { + // On garde les programmes, même si l'heure de début est passée + if (DiffTime(Programmes[i].fin, time) < 0) + // On efface les programmes dont l'heure de fin est passée + Programmes.erase(Programmes.begin()+i); + } + + // Sauvegarde à nouveau la liste des programmes + sauve_programmes(); +} + +void set_timer_record() +{ + bool trouve = false; + next_record = 0; + SYSTEMTIME time; + GetLocalTime(&time); + // On recherche le premier programme à enregistrer + for(int i = 0; i < (int)Programmes.size(); i++) { + // Recherche le premier programme, sans timer déjà programmé, à lancer + if(!Programmes[i].planifie && DiffTime(Programmes[i].debut, Programmes[next_record].debut) <= 0 && DiffTime(time, Programmes[i].fin) < 0) { + next_record = i; + trouve = true; + } + } + if (!trouve) { + next_record = -1; + myprintf(L"Plus d'enregistrements programmés\n"); + } else { + myprintf(L"next record : %i\n", next_record); + + // Calcule le temps restant jusqu'au prochain enregistrement + long temps_avant_enreg = DiffTime(Programmes[next_record].debut, time); + + // Si l'heure de début est déjà passée, on lance un timer qui aboutit immédiatement + if (temps_avant_enreg < 0) + temps_avant_enreg = USER_TIMER_MINIMUM; + + myprintf(L"Temps avant enregistrement : %i mS\n", temps_avant_enreg); + SetTimer(hMainWnd, TIMER_RECORD_START, temps_avant_enreg, NULL); + // On indique qu'un timer est placé pour cet enregistrement + Programmes[next_record].planifie = true; + } +} + +static INT_PTR CALLBACK PaswdDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { + switch (uMsg) { + case WM_INITDIALOG: + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDOK: + char buffer[256]; + buffer[0] = 127; + SendDlgItemMessage(hwndDlg, IDC_PASWD, EM_GETLINE, 0, (LPARAM)buffer); + for(int i = 1; buffer[2 * (i - 1)] != 0; i++) + buffer[i] = buffer[2 * i]; + MultiByteToWideChar(CP_ACP, 0, buffer, -1, mdp, _countof(mdp)); + EndDialog(hwndDlg, 0); + return TRUE; + case IDCANCEL: + EndDialog(hwndDlg, 1); + return TRUE; + } + return FALSE; + + default: + return FALSE; + } +} + +static int ajouter_taches(HWND hwndDlg) { + + BOOL identifie = false; + + // Parcourt rapidement pour savoir si on a des programmations à modifier + bool programmes_a_ajouter = false; + for (size_t i=0; iDelete(pwszTaskName); + // Crée la nouvelle tâche + hr = pITS->NewWorkItem(pwszTaskName, CLSID_CTask, IID_ITask, (IUnknown**)&pTask); + + pITS->Release(); + + wchar_t path[MAX_PATH]; + + // Définition de la tâche + GetModuleFileName(NULL, path, _countof(path)); + pTask->SetApplicationName(path); + pTask->SetParameters(L"-minimize"); + GetCurrentDirectory(_countof(path), path); + pTask->SetWorkingDirectory(path); + hr=pTask->SetAccountInformation(username, mdp); + pTask->SetFlags(TASK_FLAG_DELETE_WHEN_DONE | TASK_FLAG_SYSTEM_REQUIRED); + pTask->SetMaxRunTime(INFINITE); + pTask->CreateTrigger(&piNewTrigger, &pTaskTrigger); + + ZeroMemory(&Trig, sizeof(TASK_TRIGGER)); + Trig.cbTriggerSize = sizeof(TASK_TRIGGER); + Trig.wBeginDay = date.wDay; + Trig.wBeginMonth = date.wMonth; + Trig.wBeginYear = date.wYear; + Trig.wStartHour = date.wHour; + Trig.wStartMinute = date.wMinute; + + bool repetition = false; + for (int i=0; i<7; i++) + if (prog.repetition[i]) { + repetition = true; + break; + } + + if (repetition) { + // On a demandé à ce que la tâche soit répétée + Trig.TriggerType = TASK_TIME_TRIGGER_WEEKLY; + + WEEKLY jours; + jours.WeeksInterval = 1; // Répète toutes les semaines + jours.rgfDaysOfTheWeek = 0; + + if (prog.repetition[1]) + jours.rgfDaysOfTheWeek += TASK_MONDAY; + if (prog.repetition[2]) + jours.rgfDaysOfTheWeek += TASK_TUESDAY; + if (prog.repetition[3]) + jours.rgfDaysOfTheWeek += TASK_WEDNESDAY; + if (prog.repetition[4]) + jours.rgfDaysOfTheWeek += TASK_THURSDAY; + if (prog.repetition[5]) + jours.rgfDaysOfTheWeek += TASK_FRIDAY; + if (prog.repetition[6]) + jours.rgfDaysOfTheWeek += TASK_SATURDAY; + if (prog.repetition[0]) + jours.rgfDaysOfTheWeek += TASK_SUNDAY; + + Trig.Type.Weekly = jours; + } else { + // Pas de répétition de la tâche + Trig.TriggerType = TASK_TIME_TRIGGER_ONCE; + } + + pTaskTrigger->SetTrigger(&Trig); + + pTask->QueryInterface(IID_IPersistFile, (void **)&pPersistFile); + pPersistFile->Save(NULL, TRUE); + pPersistFile->Release(); + + pTaskTrigger->Release(); + pTask->Release(); + + prog.tache = planif_avec; + } + } + // On efface le mot de passe (inutile maintenant que tous les programmes sont sauvegardés) + SecureZeroMemory(mdp, sizeof(mdp)); + wcscpy(mdp, L""); + } + + return 0; +} + +static int supprimer_taches(std::vector &taches_supprimer) { + for (size_t i=0; iDelete(pwszTaskName); + + pITS->Release(); + } + + taches_supprimer.clear(); + + return 0; +} + +// Obtenir la date et l'heure d'une paire de contrôles de type "SysDateTimePick32" +void GetCtlTimeDate(HWND hDlg, int dateID, int timeID, SYSTEMTIME & result) +{ + SYSTEMTIME time_buffer; + + SendDlgItemMessage(hDlg, dateID, DTM_GETSYSTEMTIME, 0, (LPARAM)&time_buffer); + result = time_buffer; + SendDlgItemMessage(hDlg, timeID, DTM_GETSYSTEMTIME, 0, (LPARAM)&time_buffer); + result.wHour = time_buffer.wHour; + result.wMinute = time_buffer.wMinute; + result.wSecond = time_buffer.wSecond; + result.wMilliseconds = 0; +} + +/** + * Récupère les données de l'enregistrement dans la fenêtre, + * et l'ajoute aux tâches programmées. Demande la suppression de la tâche plannifiée si besoin est... + **/ +static int add_programme(HWND hwndDlg, int sel, std::vector&taches_supprimer) +{ + char buffer[256]; + int index, i; + //memset(buffer, 0, 127); + //SYSTEMTIME time_buffer; + + Programme prog; + ZeroMemory(&prog, sizeof(Programme)); + + (*(WORD *)&buffer[0]) = _countof(buffer)-1; + UINT lsiz = (UINT)SendDlgItemMessageA(hwndDlg, IDC_NAME, EM_GETLINE, 0, (LPARAM)buffer); + buffer[lsiz] = 0; + strcpy_s(prog.nom, _countof(prog.nom), buffer); + + index = (int)SendDlgItemMessage(hwndDlg, IDC_CHANNEL, CB_GETCURSEL, 0, 0); + prog.chaine = Canaux[index].numero_nit; + + GetCtlTimeDate(hwndDlg, IDC_DATE_START, IDC_TIME_START, prog.debut); + GetCtlTimeDate(hwndDlg, IDC_DATE_END, IDC_TIME_END, prog.fin); + + prog.methode = (MethodeEnregistrement)SendDlgItemMessage(hwndDlg, IDC_METHOD, CB_GETCURSEL, 0, 0); + prog.audio = (AudioMode)SendDlgItemMessage(hwndDlg, IDC_AUDIO, CB_GETCURSEL, 0, 0); + + if(IsDlgButtonChecked(hwndDlg, IDC_AFTER_POWEROFF) == BST_CHECKED) { + prog.after = apr_eteindrePC; + } else if(IsDlgButtonChecked(hwndDlg, IDC_AFTER) == BST_CHECKED) { + prog.after = apr_quitter; + } else { + prog.after = apr_rien; + } + + // Ajoute l'indicatif pour la répétition + for (i=0; i<7; i++) { + if (IsDlgButtonChecked(hwndDlg, IDC_REP_BASE+i) == BST_CHECKED) + prog.repetition[i] = true; + } + + if (IsDlgButtonChecked(hwndDlg, IDC_TACHE) == BST_CHECKED) { + prog.tache = planif_ajout; + } else { + prog.tache = planif_sans; + } + + if (!prog.verifie()) + return 1; + + // On recherche la tâche que l'on a modifiée, pour la supprimer en premier + int nbtaches = (int)taches_supprimer.size(); + + for (i=0; i taches_supprimer; + + for(i = 0; i < n; i++) { + if(SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_GETITEMSTATE, i, LVIS_SELECTED) & LVIS_SELECTED) + sel = i; + } + + switch (uMsg) { + + case WM_INITDIALOG: { + + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); + + LVCOLUMN colonne; + memset(&colonne, 0, sizeof(LVCOLUMN)); + + colonne.mask = LVCF_TEXT|LVCF_WIDTH; + + colonne.cx = 100; + colonne.pszText = L"Nom"; + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 0, (LPARAM)&colonne); + + colonne.cx = 50; + colonne.pszText = L"Chaîne"; + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 1, (LPARAM)&colonne); + + colonne.cx = 140; + colonne.pszText = L"Début"; + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 2, (LPARAM)&colonne); + + colonne.cx = 140; + colonne.pszText = L"Fin"; + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 3, (LPARAM)&colonne); + + remplit_liste_programmes(hwndDlg, IDC_LIST_PROGRAMMES); + + SYSTEMTIME time; + + GetLocalTime(&time); + + time.wSecond = 0; + time.wMilliseconds = 0; + SendDlgItemMessage(hwndDlg, IDC_TIME_START, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&time); + SendDlgItemMessage(hwndDlg, IDC_TIME_END, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&time); + + int nbchaines = (int)Canaux.size(); + + for (i=0; i= 0 && ((LPNMHDR)lParam)->code == NM_CLICK) { + const Programme & prog = Programmes[sel]; + + SendDlgItemMessageA(hwndDlg, IDC_NAME, WM_SETTEXT, 0, (LPARAM)prog.nom); + + int index = trouve_chaine(prog.chaine); + + SendDlgItemMessage(hwndDlg, IDC_CHANNEL, CB_SETCURSEL, index, 0); + + SendDlgItemMessage(hwndDlg, IDC_DATE_START, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&prog.debut); + SendDlgItemMessage(hwndDlg, IDC_TIME_START, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&prog.debut); + + SendDlgItemMessage(hwndDlg, IDC_DATE_END, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&prog.fin); + SendDlgItemMessage(hwndDlg, IDC_TIME_END, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&prog.fin); + + SendDlgItemMessage(hwndDlg, IDC_METHOD, CB_SETCURSEL, prog.methode, 0); + SendDlgItemMessage(hwndDlg, IDC_AUDIO, CB_SETCURSEL, prog.audio, 0); + + CheckDlgButton(hwndDlg, IDC_AFTER_POWEROFF, + (prog.after==apr_eteindrePC) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_AFTER, + (prog.after==apr_rien) ? BST_UNCHECKED : BST_CHECKED); + CheckDlgButton(hwndDlg, IDC_TACHE, + prog.tache ? BST_CHECKED : BST_UNCHECKED); + + // Active ou désactive le choix des pistes audio + PostMessage(hwndDlg, WM_COMMAND, (WPARAM) MAKELONG(IDC_METHOD, CBN_SELCHANGE), (LPARAM)GetDlgItem(hwndDlg, IDC_METHOD)); + + // Coche les cases pour les répétitions + for (i=0; i<7; i++) + CheckDlgButton(hwndDlg, IDC_REP_BASE+i, prog.repetition[i]); + + return TRUE; + } else + return FALSE; } + + case WM_COMMAND: + switch(LOWORD(wParam)) { + + case IDC_METHOD: + if (HIWORD(wParam) == CBN_SELCHANGE) { + int index = (int)SendDlgItemMessage(hwndDlg, IDC_METHOD, CB_GETCURSEL, 0, 0); + if (index == 0 || index ==2){ + EnableWindow(GetDlgItem( hwndDlg, IDC_AUDIO), FALSE); + } + if (index == 1) { + EnableWindow(GetDlgItem( hwndDlg, IDC_AUDIO), TRUE); + } + } + return TRUE; + + + case IDC_REMOVE: + if(sel != -1) { + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_DELETEITEM, sel, 0); + Programme &prog = Programmes[sel]; + + if (prog.tache != planif_sans) { + char *tache=new char[strlen(prog.nom)+1]; + strcpy_s(tache, strlen(prog.nom)+1, prog.nom); + taches_supprimer.push_back(tache); + } + Programmes.erase(Programmes.begin() + sel); + } + + return TRUE; + + case IDC_MODIFY: + if(sel != -1) { + Programme prog = Programmes[sel]; + Programmes.erase(Programmes.begin() + sel); + if(add_programme(hwndDlg, sel, taches_supprimer)) + Programmes.insert(Programmes.begin() + sel, prog); + return TRUE; + }else return FALSE; + + case IDC_ADD: + { + int n = (int)SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_GETITEMCOUNT, 0, 0); + add_programme(hwndDlg, (sel + n + 1) % (n + 1), taches_supprimer); + return TRUE; + } + + case IDOK: + // sauvegarder le changement + + supprimer_taches(taches_supprimer); + ajouter_taches(hwndDlg); + sauve_programmes(); + + // ... passage à travers + case IDCANCEL: + + lit_programmes(); + set_timer_record(); + DestroyWindow(hwndDlg); + return TRUE; + + case IDC_AFTER_POWEROFF: + // Coche le bouton arrêtant PouchinTV si on a demandé l'arrêt de l'ordinateur + if (IsDlgButtonChecked(hwndDlg, IDC_AFTER_POWEROFF) == BST_CHECKED) + CheckDlgButton(hwndDlg, IDC_AFTER, BST_CHECKED); + return TRUE; + + case IDC_AFTER: + // Décoche le bouton arrêtant le PC si on ne souhaite pas arrêter PouchinTV + if (IsDlgButtonChecked(hwndDlg, IDC_AFTER) == BST_UNCHECKED) + CheckDlgButton(hwndDlg, IDC_AFTER_POWEROFF, BST_UNCHECKED); + return TRUE; + } + return FALSE; + + case WM_CLOSE: + lit_programmes(); + set_timer_record(); + DestroyWindow(hwndDlg); + return TRUE; + case WM_NCDESTROY: + hRecordDlg = NULL; + ShowCursor(FALSE); // Rétablit la disparition temporisée du curseur + return FALSE; + + default: + return FALSE; + } +} + +/** + * Ouverture du dialogue des enregistrements programmés + **/ +void open_record_dialog() +{ + if (hRecordDlg) + BringWindowToTop(hRecordDlg); + else { + hRecordDlg = CreateDialog(hAppInstance, + MAKEINTRESOURCE(IDD_DELAYED_RECORD), hMainWnd, RecordDialogProc); + ShowWindow(hRecordDlg, SW_SHOW); + } +} + +/** + * Traitement des événements liés au dialogue d'enregistrement. + * Retourne 'true' si le message 'msg' a été traité, auquel cas il ne faut pas le + * passer à TranslateMessage et DispatchMessage. + * À placer dans la boucle de gestion générale des messages. + **/ +bool is_record_dialog_message(MSG & msg) { + if (hRecordDlg!=NULL && IsDialogMessage(hRecordDlg, &msg)) + return true; + return false; +} + +// Trouver la piste audio la mieux adaptée au choix de l'utilisateur lors de la programmation : +int selection_son(const un_son * sons, int nb_son, AudioMode audio) +{ + int nbr_trouve = 0; // Comptage des pistes MPEG2 trouvées + + for(int i=0; i= 2) + return i; + break; + case audio_AC3: // audio_AC3 : on retient la 1ère piste AC3 trouvée + if (son_type == 1) + return i; + } + } + + // Rien trouvé : on retient la 1ère piste audio, quelle qu'elle soit + // (dans l'espoir que ça marchera quand même, sait-on jamais ...) + return 0; +} + +// Traitement des démarrages d'enregistrements. +// Retourne le numéro de l'enregistrement qui a démarré, ou bien -1 si aucun n'a pu démarrer. +int do_record_start() +{ + Programme & prog = Programmes[next_record]; // Description de l'enregistrement à effectuer + // Chercher l'index de la chaîne dont le numéro NIT correspond à celui demandé pour + // l'enregistrement : + int index = trouve_chaine(prog.chaine); + + if (index<0) + return -1; // si on n'en a pas trouvé + + const Chaine & canal = Canaux[index]; + // + // Vérifier qu'on peut enregistrer : aucun enregistrement ne doit être déjà en cours, ou + // bien l'enregistrement en cours doit concerner le même multiplex. + long frequence_courante = Canaux[chaineCourante].frequence; + + if (recording() && canal.frequence != frequence_courante) + return -1; // si on ne peut pas enregistrer + + if (canal.frequence != frequence_courante) { + change_frequence(canal.frequence); + chaineCourante = index; + sonCourant = 0; + } + + if (!IsMinimized(hMainWnd) && suspend_minimized) + rebranche(); + + int index_son = selection_son(canal.son, canal.nb_son, prog.audio); // utilisé seulement en PS pour le moment + + int grab = -1; + + switch(prog.methode) { + case meth_TS: + grab = start_record_ts(index); + break; + case meth_PS: + grab = start_record_ps(index, index_son); + break; +#if USE_RECORD_STREAM + case meth_multiplex: { + grab = start_record_stream(); + break; } +#endif // #if USE_RECORD_STREAM + } + + // On mémorise ce qu'il faut faire à la fin de l'enregistrement programmé + enregistrements_actuels[grab].setAfter(prog.after); + + // Vérif si l'heure de début est déjà passée + SYSTEMTIME localtime; + GetLocalTime(&localtime); + SetTimer(hMainWnd, TIMER_RECORD_END_BASE+grab, + DiffTime(prog.fin, DiffTime(prog.debut, localtime) < 0 ? localtime : prog.debut), + NULL); + + // Recherche si l'enregistrement doit être répété + bool repetition = false; + for (int i=0; i<7; i++) + if (prog.repetition[i]) { + repetition = true; + break; + } + + if (repetition){ + // Recherche de la prochaine date + int recherche; + + for (recherche=prog.debut.wDayOfWeek+1; recherche<7; recherche++) + if (prog.repetition[recherche]) + break; + + if (recherche == 7) + for (recherche=0; recherche= DUREE_GRACE_QUIT*60*1000 || diff == -1)) { + // On entre ici si aucun (autre) enregistrement n'est en cours, et si aucun + // enregistrement n'est programmé pour débuter dans un délai défini par + // la constante DUREE_GRACE_QUIT. + + // Arrêt de pouchinTV ? + if (after == apr_quitter) { + if (IsMinimized(hMainWnd)) + ShowWindow(hMainWnd, SW_RESTORE); + DestroyWindow(hMainWnd); + } + // Arrêt de l'ordinateur + if (after == apr_eteindrePC) { + if (!shutdown()) { + erreur(L"Impossible d'arrêter l'ordinateur"); + } + } + } +} Added: trunk/recprog.h =================================================================== --- trunk/recprog.h (rev 0) +++ trunk/recprog.h 2007-10-14 21:37:52 UTC (rev 96) @@ -0,0 +1,103 @@ +/* + * recprog.h + * Copyright (C) 2006 Pouchin + * + * This file is part of Pouchin TV, a free DVB-T viewer. + * See http://pouchinteve.free.fr/ for updates. + * + * Pouchin TV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pouchin TV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * This was changed from the Pouchin TV project, to use with + * a modified version of this software. + * See http://pouchintv.baysse.fr/ for updates. + */ + +#pragma once + +#include "base.h" + +enum MethodeEnregistrement { + meth_TS, // 0 + meth_PS // 1 +#if USE_RECORD_STREAM + , meth_multiplex // 2 +#endif // #if USE_RECORD_STREAM +}; + +enum ApresEnregistrement { + apr_rien, // 0 + apr_quitter, // 1 + apr_eteindrePC // 2 +}; + +enum AudioMode { + audio_1, + audio_2, + audio_AC3 +}; + +enum PlanificateurTache { + planif_sans, // 0: non planifiée + planif_avec, // 1: planifiée + planif_ajout // 2: a ajouter au planificateur lors de la validation +}; + +struct Programme { + MethodeEnregistrement methode; + AudioMode audio; + ApresEnregistrement after; + PlanificateurTache tache; + SYSTEMTIME debut; + SYSTEMTIME fin; + WORD chaine; + char nom[256]; + // Tableau contenant les répétitions des enregistrements + // 0: Dimanche, 1: Lundi, ...., 6: Samedi + bool repetition[7]; + bool planifie; // Indique si un timer a été lancé pour ce programme + // + // Méthode : vérification de la validité de la programmation. + bool verifie() const; +}; + +extern std::vector Programmes; +extern int next_record; + +/** + * Traitement du chargement de la liste des programmes au démarrage, et purge + * des enregistrements périmés : + **/ +void init_programmation(); + +void set_timer_record(); + +/** + * Ouverture du dialogue des enregistrements programmés + **/ +void open_record_dialog(); + +/** + * Traitement des événements liés au dialogue d'enregistrement. + * Retourne 'true' si le message 'msg' a été traité, auquel cas il ne faut pas le + * passer à TranslateMessage et DispatchMessage. + * À placer dans la boucle de gestion générale des messages. + **/ +bool is_record_dialog_message(MSG & msg); + + +int do_record_start(); + +void do_record_stop(int grab); Modified: trunk/resource.h =================================================================== --- trunk/resource.h 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/resource.h 2007-10-14 21:37:52 UTC (rev 96) @@ -74,14 +74,15 @@ #define IDC_AFTER_POWEROFF 1064 #define IDC_POUCHINTVMOD_LOL_URL 1065 #define IDC_AUTHORS 1066 -#define IDC_REPETITIONS 1100 +#define IDC_REPETITIONS 1099 +#define IDC_REP_BASE 1100 +#define IDC_REP_DIMANCHE 1100 #define IDC_REP_LUNDI 1101 #define IDC_REP_MARDI 1102 #define IDC_REP_MERCREDI 1103 #define IDC_REP_JEUDI 1104 #define IDC_REP_VENDREDI 1105 #define IDC_REP_SAMEDI 1106 -#define IDC_REP_DIMANCHE 1107 #define MY_TRAY_ICON_ID 20001 #define MY_TRAY_ICON_MESSAGE 20002 #define IDM_QUIT 40001 Modified: trunk/search.cpp =================================================================== --- trunk/search.cpp 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/search.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -24,7 +24,6 @@ * a modified version of this software. * See http://pouchintv.baysse.fr/ for updates. */ -#include #include "base.h" Modified: trunk/settings.cpp =================================================================== --- trunk/settings.cpp 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/settings.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -27,6 +27,7 @@ #include "base.h" #include "main.h" +#include "channels.h" #include "ini.h" #include "parse.h" #include "search.h" @@ -482,7 +483,7 @@ return 0; } -/*static*/ void do_select_dir(LPWSTR dir, LPCWSTR title) +static void do_select_dir(LPWSTR dir, LPCWSTR title) { wchar_t display_name[MAX_PATH]; BROWSEINFO bi = { @@ -566,9 +567,12 @@ } } +/** + * Appel du dialogue de configuration + **/ VOID do_config(HWND hwndOwner) { - const PROPSHEETPAGE psp[] = { + const PROPSHEETPAGE psp[] = { { // Page des ressources (cartes et codecs) sizeof(PROPSHEETPAGE), // dwSize PSP_USETITLE, // dwFlags @@ -617,14 +621,15 @@ NULL // pfnCallback }; // - PropertySheet(&psh); + PropertySheet(&psh); save_config(); // sauvegarde la configuration - return; } -// Appel du dialogue de configuration en mode normal en attendant l'implémentation -// éventuelle d'un "wizard". -// Retourne IDOK si la configuration a été validée, IDCANCEL si elle a été annulée. +/** + * Appel du dialogue de configuration en mode normal en attendant l'implémentation + * éventuelle d'un "wizard". + * Retourne IDOK si la configuration a été validée, IDCANCEL si elle a été annulée. + **/ BYTE drivers_dialog() { int res = @@ -634,9 +639,11 @@ return (BYTE) res; } -// Appel du dialogue de recherche des chaînes en mode normal en attendant l'implémentation -// éventuelle d'un "wizard". -// Retourne IDOK si la configuration a été validée, IDCANCEL ou IDABORT si elle a été annulée. +/** + * Appel du dialogue de recherche des chaînes en mode normal en attendant l'implémentation + * éventuelle d'un "wizard". + * Retourne IDOK si la configuration a été validée, IDCANCEL ou IDABORT si elle a été annulée. + **/ BYTE scan_dialog() { int res = Modified: trunk/settings.h =================================================================== --- trunk/settings.h 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/settings.h 2007-10-14 21:37:52 UTC (rev 96) @@ -27,18 +27,21 @@ #pragma once -// Appel du dialogue de configuration en mode normal en attendant l'implémentation -// éventuelle d'un "wizard". -// Retourne IDOK si la configuration a été validée, IDCANCEL si elle a été annulée. +/** + * Appel du dialogue de configuration en mode normal en attendant l'implémentation + * éventuelle d'un "wizard". + * Retourne IDOK si la configuration a été validée, IDCANCEL si elle a été annulée. + **/ BYTE drivers_dialog(); -// Appel du dialogue de recherche des chaînes en mode normal en attendant l'implémentation -// éventuelle d'un "wizard". -// Retourne IDOK si la configuration a été validée, IDCANCEL ou IDABORT si elle a été annulée. +/** + * Appel du dialogue de recherche des chaînes en mode normal en attendant l'implémentation + * éventuelle d'un "wizard". + * Retourne IDOK si la configuration a été validée, IDCANCEL ou IDABORT si elle a été annulée. + **/ BYTE scan_dialog(); -// Appel du dialogue de choix des répertoires de capture en attendant qu'on supprime -// l'appel de cette fonction depuis les menus -void do_select_dir(LPWSTR dir, LPCWSTR title); - +/** + * Appel du dialogue de configuration + **/ VOID do_config(HWND hwndOwner); Modified: trunk/trayicon.cpp =================================================================== --- trunk/trayicon.cpp 2007-10-14 18:33:26 UTC (rev 95) +++ trunk/trayicon.cpp 2007-10-14 21:37:52 UTC (rev 96) @@ -27,8 +27,9 @@ #include "base.h" #include "main.h" - +#include "channels.h" #include "trayicon.h" +#include "record.h" MyNOTIFYICONDATA niData; From pouchintv-svn at baysse.fr Wed Oct 17 00:10:38 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Wed, 17 Oct 2007 00:10:38 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r97 - trunk Message-ID: <20071016221038.F3AB55F2ED@mail.baysse.fr> Author: gingko Date: 2007-10-17 00:10:38 +0200 (Wed, 17 Oct 2007) New Revision: 97 Modified: trunk/ini.cpp trunk/main.cpp Log: Correction d'un bug introduit par moi-m?\195?\170me, qui fait que maintenant, il peut arriver que le menu des pistes ou bien la barre d'?\195?\169tat soient mis ?\195?\160 jour alors qu'aucune cha?\195?\174ne n'est encore active. D'o?\195?\185 plantage. Par ailleurs, ayant ?\195?\169t?\195?\169 amen?\195?\169 ?\195?\160 tester PouchinTV Mod sur une installation de Windows XP quasi vierge de toute autre application, j'ai constat?\195?\169 ?\195?\160 cette occasion que le r?\195?\169pertoire "Mes vid?\195?\169os" n'y ?\195?\169tait pas d?\195?\169fini. J'ai donc fait en sorte que dans un tel cas, ce soit le r?\195?\169pertoire "Mes Documents" qui devienne le r?\195?\169pertoire par d?\195?\169faut. Idem pour "Mes Images". Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-14 21:37:52 UTC (rev 96) +++ trunk/ini.cpp 2007-10-16 22:10:38 UTC (rev 97) @@ -780,6 +780,8 @@ wchar_t default_dir[MAX_PATH]; SHGetFolderPath(NULL, nDefaultFolder, NULL, SHGFP_TYPE_CURRENT, default_dir); + if (default_dir[0] == 0) + SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, default_dir); return load_config_str(lpKeyName, lpValue, nSize, default_dir); } Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-10-14 21:37:52 UTC (rev 96) +++ trunk/main.cpp 2007-10-16 22:10:38 UTC (rev 97) @@ -447,6 +447,9 @@ static void update_pistes_menu(HMENU hMenu) { + if (chaineCourante < 0 || chaineCourante >= (int)Canaux.size()) + return; + struct Langue { char code[4]; LPCSTR lang; @@ -751,6 +754,9 @@ static void update_status_bar(void) { + if (chaineCourante < 0 || chaineCourante >= (int)Canaux.size()) + return; + const Chaine & canal_courant = Canaux[chaineCourante]; if (!is_vista) { @@ -1210,9 +1216,7 @@ update_status_size(); - - if (chaineCourante >=0 && chaineCourante < (int)Canaux.size()) - update_status_bar(); + update_status_bar(); } static bool remove_borders() From pouchintv-svn at baysse.fr Sat Oct 20 15:36:58 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Sat, 20 Oct 2007 15:36:58 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r98 - trunk Message-ID: <20071020133658.D18CC5F2F2@mail.baysse.fr> Author: gingko Date: 2007-10-20 15:36:58 +0200 (Sat, 20 Oct 2007) New Revision: 98 Modified: trunk/LCD.cpp trunk/LCD.h trunk/base.cpp trunk/base.h trunk/channels.cpp trunk/channels.h trunk/epg.cpp trunk/epgfilter.cpp trunk/ini.cpp trunk/ini.h trunk/main.cpp trunk/main.h trunk/parse.cpp trunk/parse.h trunk/pmtfilter.cpp trunk/record.cpp trunk/record.h trunk/recprog.cpp trunk/recprog.h trunk/res.rc trunk/settings.cpp trunk/trayicon.cpp Log: Modification de la d?\195?\169signation des cha?\195?\174nes dans les enregistrements programm?\195?\169s ainsi que dans la configuration (sauvegarde de la cha?\195?\174ne courante) : on utilise maintenant l'identifiant de service (SID) de la cha?\195?\174ne, dont il est pr?\195?\169sum?\195?\169 qu'il sera moins susceptible de varier que les autres types d'identifiants. Les cha?\195?\174nes pouvant ?\195?\170tre d?\195?\169sign?\195?\169es de trois mani?\195?\168res diff?\195?\169rentes (par num?\195?\169ro, par SID et par index dans la table), les variables qui contiennent ces identifiants ont ?\195?\169t?\195?\169 renomm?\195?\169es de fa?\195?\167on ?\195?\160 faire ressortir clairement ?\195?\160 quel type on a affaire (typiquement 'numeroChaine' ou 'numChaine' pour num?\195?\169ro, 'sidChaine' pour SID et 'ixChaine' ou 'indexChaine' pour l'index, plus quelques variantes). Quelques variables analogues (index son ...) sont ?\195?\169galement concern?\195?\169es. Ajout d'un second syst?\195?\168me de num?\195?\169rotation automatique des cha?\195?\174nes dans l'hypoth?\195?\168se o?\195?\185 la liste NIT incluse dans les multiplex n'existe pas ou ne pourrait ?\195?\170tre lue : dans ce cas, les cha?\195?\174nes sont num?\195?\169rot?\195?\169es s?\195?\169quentiellement dans leur ordre alphab?\195?\169tique. Ce syst?\195?\168me devrait ?\195?\169galement g?\195?\169rer correctement le traitement d'une NIT qui ne r?\195?\169f?\195?\169rencerait qu'une partie des cha?\195?\174nes (auquel cas seules les cha?\195?\174nes restantes seraient ainsi renum?\195?\169rot?\195?\169es, en ?\195?\169vitant les doublons avec les num?\195?\169ros attribu?\195?\169s). En relation avec ce qui pr?\195?\169c?\195?\168de, pendant la recherche de cha?\195?\174nes, un num?\195?\169ro de chaine ?\195?\169gal ?\195?\160 z?\195?\169ro (donc non encore d?\195?\169termin?\195?\169 ?\195?\160 ce stade) s'affiche maitenant comme un tiret. Ajout d'une fonction 'ixChaine_ok' pour faciliter la v?\195?\169rification de la validit?\195?\169 des index dans la table des cha?\195?\174nes (source de pas mal de plantages dans le pass?\195?\169). Le dialogue d'arr?\195?\170t temporis?\195?\169 de l'enregistrement contient maintenant, lui aussi, la possibilit?\195?\169 de quitter PouchinTV ou d'?\195?\169teindre l'ordinateur ?\195?\160 la fin de l'enregistrement. Dans le dialogue des enregistrements programm?\195?\169s, les noms des cha?\195?\174nes apparaissent maintenant en clair, et non plus par num?\195?\169ro. Toujours dans ce dialogue, les champs de d?\195?\169but et de fin d'enregistrement s'influencent maintenant mutuellement : si on modifie l'heure de d?\195?\169but, l'heure de fin est ajust?\195?\169e pour ne jamais ?\195?\170tre inf?\195?\169rieure au d?\195?\169but, et inversement. La programmation d'un enregistrement depuis le guide des programmes met maintenant ?\195?\160 jour la liste des enregistrements programm?\195?\169s dans le cas o?\195?\185 les deux dialogues sont ouverts simultan?\195?\169ment. En cas de chevauchement incompatible de deux programmations, le message d'erreur inclut maintenant le nom de la cha?\195?\174ne en conflit. La lecture du fichier des cha?\195?\174nes intervient plus t?\195?\180t dans l'initialisation, car certaines fonctions peuvent maintenant en avoir besoin pour convertir le SID en index ou en num?\195?\169ro de cha?\195?\174ne. Quelques fonctions d?\195?\169plac?\195?\169es. Modified: trunk/LCD.cpp =================================================================== --- trunk/LCD.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/LCD.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -252,8 +252,8 @@ TextOutA(this->m_hdc, tm.tmAveCharWidth * 8, (tm.tmHeight + 1)*2, this->m_prog_suivant, (int)strlen(this->m_prog_suivant)); } -void CLcd::SetChaine(const char *chaine){ - strcpy_s(this->m_chaine, 256, chaine); +void CLcd::SetChaine(const char *nomChaine){ + strcpy_s(this->m_chaine, 256, nomChaine); } void CLcd::SetProgrammeActuel(const char *heure, const char *programme){ Modified: trunk/LCD.h =================================================================== --- trunk/LCD.h 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/LCD.h 2007-10-20 13:36:58 UTC (rev 98) @@ -79,7 +79,7 @@ DWORD ActualiseLcd(); // Définit la chaine - void SetChaine(const char *chaine); + void SetChaine(const char *nomChaine); // Définit le programme actuel void SetProgrammeActuel(const char *heure, const char *programme); Modified: trunk/base.cpp =================================================================== --- trunk/base.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/base.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -89,8 +89,8 @@ #endif //#if USE_CONSOLE==1 -void erreur(const wchar_t * chaine) +void erreur(const wchar_t * str) { - MessageBox(hMainWnd, chaine, NULL, MB_ICONERROR); + MessageBox(hMainWnd, str, NULL, MB_ICONERROR); } Modified: trunk/base.h =================================================================== --- trunk/base.h 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/base.h 2007-10-20 13:36:58 UTC (rev 98) @@ -192,4 +192,4 @@ etf_minimized // minimisée (en icône ou pas) }; -void erreur(const wchar_t * chaine); +void erreur(const wchar_t * str); Modified: trunk/channels.cpp =================================================================== --- trunk/channels.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/channels.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -30,12 +30,158 @@ #include "main.h" #include "record.h" #include "graph.h" +#include "ini.h" std::vector Canaux; -int chaineCourante = -1; -int sonCourant = 0; +int ixChaineCourante = -1; +int ixSonCourant = 0; long volumeCourant = 0; +// Taille des images des chaines (largeur et longueur) +#define TAILLE_IMAGE_CHAINE 16 + +HBITMAP cherche_icone(LPCWSTR dir, LPCSTR nom) +{ + wchar_t pathName[MAX_PATH]; + WIN32_FIND_DATA file_data; + HBITMAP hImage = NULL; + + // Concaténation chemin + chaîne + swprintf_s(pathName, _countof(pathName), L"%s\\Icones\\%S.bmp", dir, nom); + + HANDLE handle = FindFirstFile(pathName, &file_data); + if (handle != INVALID_HANDLE_VALUE) { + // Fichier trouvé. + hImage = (HBITMAP)LoadImage(NULL, pathName, IMAGE_BITMAP, + TAILLE_IMAGE_CHAINE, TAILLE_IMAGE_CHAINE, LR_LOADFROMFILE | LR_LOADTRANSPARENT); + FindClose(handle); + } + + return hImage; +} + +HBITMAP Chaine::ChargeIcone() +{ + if (hImage==INVALID_HANDLE_VALUE) + return NULL; + + if (hImage==NULL) { + /** + * Charge les bitmaps des chaînes + **/ + NomProtege nom_canal(nom, '_'); + + hImage = cherche_icone(pouchindir_conf, nom_canal.nom); + + // Ne recherche que si le dossier de config est différent du dossier du programme + if (hImage == NULL && wcscmp(pouchindir_conf, pouchindir_prog) != 0) { + // Le fichier n'a pas été trouvé dans le dossier des configs. + // Recherche dans le dossier de Pouchin TV Mod + + hImage = cherche_icone(pouchindir_prog, nom_canal.nom); + if (hImage == NULL) { + // Toujours pas trouvé : on met INVALID_HANDLE_VALUE pour se rappeler de ne plus le + // rechercher avant le prochain lancement du programme. + hImage = (HBITMAP)INVALID_HANDLE_VALUE; + } + } + } + + return hImage; +} + +/** + * Recherche de l'index correspondant à un numéro de chaîne 'numChaine'. + * Retourne -1 si pas trouvé. + **/ +int trouve_chaine_par_no(WORD numChaine) +{ + int nbchaines = (int)Canaux.size(); + + for (int i=0; i=0 && ixChaine<(int)Canaux.size(); +} + +/** + * Tri des chaînes par numéro. + * En cas d'identité de numéro (numéro pas attribué = 0, par exemple), + * les noms de chaînes sont comparés. + **/ +void trie_chaines() +{ + int nbChaines = (int)Canaux.size(); + + // un vieux tri bulles :o + for (int i = 0; iStartChanges(); @@ -97,7 +243,7 @@ void switch_audio(int old_son, int new_son) { - const un_son * son_courant = Canaux[chaineCourante].son; + const un_son * son_courant = Canaux[ixChaineCourante].son; ULONG old_pid = son_courant[old_son].pid; ULONG new_pid = son_courant[new_son].pid; @@ -116,16 +262,16 @@ pMapSound->MapPID(1, &new_pid, MEDIA_ELEMENTARY_STREAM); } - sonCourant=new_son; + ixSonCourant=new_son; } // Changement de chaîne pour la chaîne dont l'index est donné en paramètre. // Retourne 0 si pas d'erreur, 1 si le changement n'a pas pu avoir lieu -int change_chaine(int index_chaine) +int change_chaine(int ixChaine) { bool freq_differente = true; - if (chaineCourante >= 0 && index_chaine >= 0 && - Canaux[chaineCourante].frequence == Canaux[index_chaine].frequence) + if (ixChaine_ok(ixChaineCourante) && ixChaine_ok(ixChaine) && + Canaux[ixChaineCourante].frequence == Canaux[ixChaine].frequence) { freq_differente = false; } @@ -135,15 +281,12 @@ debranche(); - if (index_chaine >= 0 && index_chaine<(int)Canaux.size()) - chaineCourante = index_chaine; - else - chaineCourante = -1; + ixChaineCourante = ixChaine_ok(ixChaine) ? ixChaine : -1; - if (chaineCourante >= 0) { - const Chaine & nouveau_canal = Canaux[chaineCourante]; + if (ixChaineCourante >= 0) { + const Chaine & nouveau_canal = Canaux[ixChaineCourante]; - myprintf(L"zappe %i\n", chaineCourante+1); + myprintf(L"zappe %i\n", ixChaineCourante+1); myprintf(L"SID %i, TSID %i, ONID %i, freq : %i\n", nouveau_canal.SID, nouveau_canal.TSID, nouveau_canal.ONID, nouveau_canal.frequence); if (freq_differente) @@ -162,7 +305,7 @@ for (int i=0; iMapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); - sonCourant=0; + ixSonCourant=0; myprintf(L"%?erreur pid son, hr=0x%08x\n", FAILED(hr), hr); } } @@ -193,15 +336,15 @@ void rebranche() { - const Chaine & canal_courant = Canaux[chaineCourante]; + const Chaine & canal_courant = Canaux[ixChaineCourante]; HRESULT hr; ULONG pid = canal_courant.video_pid; hr = pMapMPEG2->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); myprintf(L"%?erreur pid video, hr=0x%08x\n", FAILED(hr), hr); - pid = canal_courant.son[sonCourant].pid; - if (canal_courant.son[sonCourant].type == 1) { + pid = canal_courant.son[ixSonCourant].pid; + if (canal_courant.son[ixSonCourant].type == 1) { hr = pMapAc3->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM); myprintf(L"%?erreur pid ac3, hr=0x%08x\n", FAILED(hr), hr); } else { Modified: trunk/channels.h =================================================================== --- trunk/channels.h 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/channels.h 2007-10-20 13:36:58 UTC (rev 98) @@ -64,7 +64,7 @@ WORD ONID; WORD TSID; WORD SID; - WORD numero_nit; + WORD numeroChaine; }; struct Chaine : public ChainePMT, public ChaineIDs { @@ -82,13 +82,20 @@ Chaine() : hImage(NULL) {} // HBITMAP ChargeIcone(); + // + // Fonction retournant 'true' si cette chaîne a un rang supérieur de classement + // à celui de la chaîne 'canal2'. + bool compare(const Chaine & canal2) const // inline + { return + numeroChaine > canal2.numeroChaine || + (numeroChaine == canal2.numeroChaine && _stricmp(nom, canal2.nom) > 0); } }; // Tableau des chaînes extern std::vector Canaux; -extern int chaineCourante; // Index de la chaîne couramment utilisée -extern int sonCourant; // Index de la piste sonore couramment utilisée +extern int ixChaineCourante; // Index de la chaîne couramment utilisée +extern int ixSonCourant; // Index de la piste sonore couramment utilisée extern long volumeCourant; // Niveau de volume sonore courant void change_frequence(ULONG freq); @@ -97,7 +104,7 @@ // Changement de chaîne pour la chaîne dont l'index est donné en paramètre. // Retourne 0 si pas d'erreur, 1 si le changement n'a pas pu avoir lieu -int change_chaine(int index_chaine); +int change_chaine(int ixChaine); // Changement de piste son : void switch_audio(int old_son, int new_son); @@ -109,7 +116,32 @@ void rebranche(); /** - * Recherche de l'index correspondant à un numéro de chaîne 'numero_nit'. + * Recherche de l'index correspondant à un numéro de chaîne 'numChaine'. * Retourne -1 si pas trouvé. **/ -int trouve_chaine(WORD numero_nit); +int trouve_chaine_par_no(WORD numChaine); + +/** + * Recherche de l'index correspondant à un service ID de chaîne 'sidChaine'. + * Retourne -1 si pas trouvé. + **/ +int trouve_chaine_par_sid(WORD sidChaine); + +/** + * Retourne 'true' si l'index de chaîne passé en paramètre est valide. + **/ +inline bool ixChaine_ok(int ixChaine); + +/** + * Tri des chaînes par numéro. + * En cas d'identité de numéro (numéro pas attribué = 0, par exemple), + * les noms de chaînes sont comparés. + **/ +void trie_chaines(); + +/** + * Attribution d'un numéro à toutes les chaînes qui n'en ont pas reçu. + * Si les chaînes ont été triées auparavant, ce numéro sera attribué selon l'ordre + * alphabétique de leur nom. + **/ +void attribue_numeros(); Modified: trunk/epg.cpp =================================================================== --- trunk/epg.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/epg.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -49,7 +49,7 @@ // if ( canal.emis[0].debut.QuadPart != 0) { item.lParam = 2 * i; - if (i ==(size_t)chaineCourante) visible_index = cpt; + if (i ==(size_t)ixChaineCourante) visible_index = cpt; item.iItem = cpt; item.pszText = canal.nom; @@ -125,9 +125,10 @@ planif_sans, // tache emis.debut2, // debut emis.fin2, // fin - canal.numero_nit // chaine + canal.numeroChaine, // numeroChaine + canal.SID // sidChaine // - // tout le reste à zéro + // tout le reste à zéro (implicite) }; strcpy_s(prog.nom, _countof(prog.nom), emis.nom); @@ -135,6 +136,7 @@ return 1; Programmes.insert(Programmes.begin() + Programmes.size(), prog); + update_record_list(); sauve_programmes(); return 0; // 0 = pas d'erreur } Modified: trunk/epgfilter.cpp =================================================================== --- trunk/epgfilter.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/epgfilter.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -263,7 +263,7 @@ } // passe par le thread graphique pour updater, sinon ça plante - if (chaineEit == chaineCourante) + if (chaineEit == ixChaineCourante) PostMessage(hMainWnd, WM_USER, 0, 0); offset += len; Modified: trunk/ini.cpp =================================================================== --- trunk/ini.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/ini.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -50,9 +50,6 @@ #define freq_canal(x) (x * 8000 + freq_offset) -// Taille des images des chaines (largeur et longueur) -#define TAILLE_IMAGE_CHAINE 16 - static wchar_t config_file[] = L"\\config.ini"; static wchar_t ini_config[] = L"Config"; #if _DEBUG @@ -66,7 +63,7 @@ #endif // #if _DEBUG static wchar_t ini_nom_ville[] = L"Ville"; static wchar_t ini_strict[] = L"Recherche stricte"; -static wchar_t ini_chaine_courante[] = L"Index chaîne courante"; +static wchar_t ini_chaine_courante[] = L"Identifiant chaîne courante"; static wchar_t ini_rep_video[] = L"Répertoire vidéo"; static wchar_t ini_rep_screen[] = L"Répertoire screenshots"; static wchar_t ini_priorite[] = L"Priorité"; @@ -150,56 +147,6 @@ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } -HBITMAP cherche_icone(LPCWSTR dir, LPCSTR nom) -{ - wchar_t pathName[MAX_PATH]; - WIN32_FIND_DATA file_data; - HBITMAP hImage = NULL; - - // Concaténation chemin + chaîne - swprintf_s(pathName, _countof(pathName), L"%s\\Icones\\%S.bmp", dir, nom); - - HANDLE handle = FindFirstFile(pathName, &file_data); - if (handle != INVALID_HANDLE_VALUE) { - // Fichier trouvé. - hImage = (HBITMAP)LoadImage(NULL, pathName, IMAGE_BITMAP, - TAILLE_IMAGE_CHAINE, TAILLE_IMAGE_CHAINE, LR_LOADFROMFILE | LR_LOADTRANSPARENT); - FindClose(handle); - } - - return hImage; -} - -HBITMAP Chaine::ChargeIcone() -{ - if (hImage==INVALID_HANDLE_VALUE) - return NULL; - - if (hImage==NULL) { - /** - * Charge les bitmaps des chaînes - **/ - NomProtege nom_canal(nom, '_'); - - hImage = cherche_icone(pouchindir_conf, nom_canal.nom); - - // Ne recherche que si le dossier de config est différent du dossier du programme - if (hImage == NULL && wcscmp(pouchindir_conf, pouchindir_prog) != 0) { - // Le fichier n'a pas été trouvé dans le dossier des configs. - // Recherche dans le dossier de Pouchin TV Mod - - hImage = cherche_icone(pouchindir_prog, nom_canal.nom); - if (hImage == NULL) { - // Toujours pas trouvé : on met INVALID_HANDLE_VALUE pour se rappeler de ne plus le - // rechercher avant le prochain lancement du programme. - hImage = (HBITMAP)INVALID_HANDLE_VALUE; - } - } - } - - return hImage; -} - BOOL save_config_int(LPCWSTR lpKeyName, LONG value); // forward void lit_fichier_scan(wchar_t * ville) @@ -360,8 +307,18 @@ pNode->getStr(L"Nom", (char*)prog.nom); - prog.chaine = (WORD)pNode->getInt(L"Chaine"); + prog.numeroChaine = (WORD)pNode->getInt(L"Chaine"); + prog.sidChaine = (WORD)pNode->getInt(L"ServiceID"); + // Ajustement de compatibilité permettant de récupérer correctement les programmations + // faites avec les anciennes versions qui ne sauvegardaient pas le SID. + if (prog.sidChaine==0) { + int ixChaine = trouve_chaine_par_no(prog.numeroChaine); + + if (ixChaine_ok(ixChaine)) + prog.sidChaine = Canaux[ixChaine].SID; + } + // Récupère les heures/dates de début d'enregistrement CXMLNode *enregistrements = NULL; pNode->getChildrenByName(L"Début", &enregistrements); @@ -447,8 +404,9 @@ fprintf(fop, "\t\n" "\t\t%s\n" - "\t\t%i\n", - programme.nom, programme.chaine); + "\t\t%i\n" + "\t\t%i\n", + programme.nom, programme.numeroChaine, programme.sidChaine); xmlSaveSystemTime(fop, "Début", programme.debut); xmlSaveSystemTime(fop, "Fin", programme.fin); @@ -477,7 +435,11 @@ fclose(fop); } -int lit_chaines(void) +/** + * Chargement du fichier des chaînes "chaines.xml". + * Retourne 0 en cas de succès, 1 si erreur. + **/ +int lit_chaines() { CXMLWrapper xml; wchar_t fileName[MAX_PATH]; @@ -511,7 +473,7 @@ canal.TSID = (WORD)pNode->getInt(L"TSID"); canal.SID = (WORD)pNode->getInt(L"SID"); - canal.numero_nit = (WORD)pNode->getInt(L"Numero"); + canal.numeroChaine = (WORD)pNode->getInt(L"Numero"); canal.pmt_pid = (WORD)pNode->getInt(L"PMT"); canal.pcr_pid = (WORD)pNode->getInt(L"PCR"); @@ -578,7 +540,7 @@ fprintf(fop, "\t\t%i\n", canal.TSID); fprintf(fop, "\t\t%i\n", canal.SID); - fprintf(fop, "\t\t%i\n", canal.numero_nit); + fprintf(fop, "\t\t%i\n", canal.numeroChaine); fprintf(fop, "\t\t%i\n", canal.pmt_pid); fprintf(fop, "\t\t%i\n", canal.pcr_pid); @@ -710,7 +672,7 @@ save_config_str(ini_filtre_ac3, filtreAc3); save_config_str(ini_nom_ville, nomVille); save_config_bool(ini_strict, exact_match==TRUE); - save_config_int(ini_chaine_courante, chaineCourante); + save_config_int(ini_chaine_courante, ixChaine_ok(ixChaineCourante) ? Canaux[ixChaineCourante].SID : 0); save_config_str(ini_rep_video, video_dir); save_config_str(ini_rep_screen, screenshots_dir); save_config_assoc(ini_priorite, aPrioTable, get_priority()); @@ -819,7 +781,7 @@ load_config_str(ini_nom_ville, nomVille, _countof(nomVille)); exact_match = load_config_bool(ini_strict, true); - nouvelleChaine = (WORD)load_config_int(ini_chaine_courante, 0); + sidChaineConfig = (WORD)load_config_int(ini_chaine_courante, 0); // CSIDL_MYVIDEO : Répertoire "Mes vidéos" (utilisé par défaut) load_config_path(ini_rep_video, video_dir, _countof(video_dir), CSIDL_MYVIDEO); @@ -877,42 +839,6 @@ } } -void remplit_liste_programmes(HWND hdlg, int item) -{ - int nbProgrammes = (int)Programmes.size(); - - LVITEMA prog; - memset(&prog, 0, sizeof(LVITEMA)); - - prog.mask = LVIF_TEXT; - - char buffer[256]; - - for(prog.iItem=0; prog.iItem(programme.nom); - SendDlgItemMessage(hdlg, item, LVM_INSERTITEMA, 0, (LPARAM)&prog); - prog.iSubItem = 1; - sprintf_s(buffer, _countof(buffer), "%u", programme.chaine); - prog.pszText = buffer; - SendDlgItemMessage(hdlg, item, LVM_SETITEMA, 0, (LPARAM)&prog); - prog.iSubItem = 2; - sprintf_s(buffer, _countof(buffer), "%02i:%02i:%02i %02i/%02i/%04i", - programme.debut.wHour, programme.debut.wMinute, programme.debut.wSecond, - programme.debut.wDay, programme.debut.wMonth, programme.debut.wYear); - prog.pszText = buffer; - SendDlgItemMessage(hdlg, item, LVM_SETITEMA, 0, (LPARAM)&prog); - prog.iSubItem = 3; - sprintf_s(buffer, _countof(buffer), "%02i:%02i:%02i %02i/%02i/%04i", - programme.fin.wHour, programme.fin.wMinute, programme.fin.wSecond, - programme.fin.wDay, programme.fin.wMonth, programme.fin.wYear); - prog.pszText = buffer; - SendDlgItemMessage(hdlg, item, LVM_SETITEMA, 0, (LPARAM)&prog); - } -} - // vérifier que tuner TNT est valide bool check_config(void) { Modified: trunk/ini.h =================================================================== --- trunk/ini.h 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/ini.h 2007-10-20 13:36:58 UTC (rev 98) @@ -28,14 +28,19 @@ #pragma once void lit_fichier_scan(wchar_t * ville); -int lit_chaines(void); + +/** + * Chargement du fichier des chaînes "chaines.xml". + * Retourne 0 en cas de succès, 1 si erreur. + **/ +int lit_chaines(); + void sauve_chaines(void); int lit_programmes(void); void sauve_programmes(void); void save_config(void); void load_config(void); void remplit_villes(HWND hItm); -void remplit_liste_programmes(HWND hdlg, int item); bool check_config(void); // Structure pour la sauvegarde de la position des fenêtres : Modified: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/main.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -74,7 +74,9 @@ wchar_t screenshots_dir[MAX_PATH]; wchar_t video_dir[MAX_PATH]; -WORD nouvelleChaine = 0; +WORD numeroChaineSaisi = 0; +WORD sidChaineConfig = 0; + wchar_t statusvol[40]; static bool muted = false; @@ -373,8 +375,8 @@ static void update_menu_recording(HMENU hMenu) { - bool can_rec = !(getFreeGrabber() == -1 || getGrabberChaine(chaineCourante) != -1); - bool can_stop = getGrabberChaine(chaineCourante) != -1; + bool can_rec = !(getFreeGrabber() == -1 || getGrabberChaine(ixChaineCourante) != -1); + bool can_stop = getGrabberChaine(ixChaineCourante) != -1; set_menu_enable_state(hMenu, IDM_RECORD_CHANNEL_PS, can_rec); set_menu_enable_state(hMenu, IDM_RECORD_CHANNEL_TS, can_rec); @@ -447,7 +449,7 @@ static void update_pistes_menu(HMENU hMenu) { - if (chaineCourante < 0 || chaineCourante >= (int)Canaux.size()) + if (!ixChaine_ok(ixChaineCourante)) return; struct Langue { @@ -467,7 +469,7 @@ {"por", "Portugais"} }; - const Chaine & canal_courant = Canaux[chaineCourante]; + const Chaine & canal_courant = Canaux[ixChaineCourante]; UINT position_menu = cherche_menu(hMenu, L"Pistes"); // Récupère le nom du menu avant de l'effacer @@ -496,7 +498,7 @@ swprintf_s(tab, _countof(tab), L"Audio %i %S (%s)", i+1, langue, (son_courant.type==1) ? L"AC3" : L"MPG"); - AppendMenu(pistes, (i==sonCourant) ? MF_CHECKED : MF_UNCHECKED, 500+i, tab); + AppendMenu(pistes, (i==ixSonCourant) ? MF_CHECKED : MF_UNCHECKED, 500+i, tab); } InsertMenu(hMenu, position_menu, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)pistes, nom_menu); @@ -518,11 +520,11 @@ for (size_t i=0; i= (int)Canaux.size()) + if (!ixChaine_ok(ixChaineCourante)) return; - const Chaine & canal_courant = Canaux[chaineCourante]; + const Chaine & canal_courant = Canaux[ixChaineCourante]; if (!is_vista) { RedrawWindow(hMainWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); @@ -810,9 +812,9 @@ niData.update_tip(); } -void zappe_index(int index_chaine) +void zappe_index(int ixChaine) { - if (change_chaine(index_chaine)==0) { + if (change_chaine(ixChaine)==0) { update_all_menus(hMainWnd); update_status_bar(); @@ -824,13 +826,27 @@ } } -void zappe_chaine(WORD numero_chaine) +/** + * Restauration d'une chaîne sauvegardée par SID. + * Si le SID n'est pas valide, on utilise la première de la liste. + * Retourne 'true' si succès, 'false' si la liste est vide. + **/ +bool restaure_chaine(WORD sidChaine) { - // cherche l'index de la chaîne voulue - int index_chaine = trouve_chaine(numero_chaine); + // On essaye de remettre la même chaîne qu'avant, s'il y en avait une : + if (!Canaux.empty()) { + int ixChaine = trouve_chaine_par_sid(sidChaine); - if (index_chaine != -1) - zappe_index(index_chaine); + if (ixChaine<0) { + // S'il n'y en avait pas, ou bien si cette chaîne n'est plus captée, + // on met la première de la liste ... + // ... laquelle a toutes les chances d'être TF1, mais bon ... :-( + ixChaine = 0; + } + zappe_index(ixChaine); + return true; + } + return false; } void switch_etat_fenetre(EtatsFenetre nouvel_etat); // forward @@ -858,29 +874,15 @@ return 1; } - if (Canaux.size() == 0) { + if (Canaux.size() > 0) { + restaure_chaine(sidChaineConfig); + } else { erreur(L"Aucune chaîne n'est dans le fichier"); + update_all_menus(hMainWnd); } - // restaure l'option on top - - //on_top = !on_top; // supprimé car implicite dans la nouvelle - //switch_on_top(); // gestion de fenêtres - - if (nouvelleChaine < 0 || nouvelleChaine >= (int)Canaux.size()) { - nouvelleChaine = 0; - } - - if (Canaux.size() > 0) - zappe_index(nouvelleChaine); - else - update_all_menus(hMainWnd); // -> sinon, "zappe_index" le fait déjà - set_volume(volumeCourant); - - nouvelleChaine = 0; - return 0; } @@ -1149,47 +1151,9 @@ CoTaskMemFree( caGUID.pElems ); } -static INT_PTR CALLBACK DelayedStopDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - SYSTEMTIME time; - UINT delayed; - int grab; - - switch (uMsg) { - case WM_INITDIALOG: - GetLocalTime(&time); - - time.wHour = 0; - time.wMinute = 0; - time.wSecond = 0; - time.wMilliseconds = 0; - SendDlgItemMessage(hwndDlg, IDC_DELAYED_STOP, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&time); - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - grab = getGrabberChaine(chaineCourante); - if (grab>=0) { - KillTimer(hMainWnd, TIMER_RECORD_END_BASE+grab); - SendDlgItemMessage(hwndDlg, IDC_DELAYED_STOP, DTM_GETSYSTEMTIME, 0, (LPARAM)&time); - delayed = ((time.wHour*60 + time.wMinute)*60 + time.wSecond)*1000; - - SetTimer(hMainWnd, TIMER_RECORD_END_BASE+grab, delayed, NULL); - } - case IDCANCEL: - EndDialog(hwndDlg, 0); - return TRUE; - } - // ... - default: - return FALSE; - } -} - - static void traite_numero(int nb) { - nouvelleChaine = (nouvelleChaine * 10 + (WORD)nb) % 1000; + numeroChaineSaisi = (numeroChaineSaisi * 10 + (WORD)nb) % 1000; // (modulo 1000 au cas où il y aurait trop de chiffres) SetTimer(hMainWnd, TIMER_NUMBER, 1000, NULL); @@ -1379,21 +1343,21 @@ static void chaine_precedente() { if (!recording()) { - int nouvelle = chaineCourante - 1; + int nouvelle = ixChaineCourante - 1; if (nouvelle < 0) nouvelle = (int)Canaux.size()-1; zappe_index(nouvelle); } else { // faut trouver une chaîne avant avec la même fréq - for (int i = chaineCourante -1; i>=0; i--) { - if (Canaux[i].frequence == Canaux[chaineCourante].frequence) { + for (int i = ixChaineCourante -1; i>=0; i--) { + if (Canaux[i].frequence == Canaux[ixChaineCourante].frequence) { zappe_index(i); return; } } - for (int i = (int)Canaux.size() -1; i>chaineCourante; i--) { - if (Canaux[i].frequence == Canaux[chaineCourante].frequence) { + for (int i = (int)Canaux.size() -1; i>ixChaineCourante; i--) { + if (Canaux[i].frequence == Canaux[ixChaineCourante].frequence) { zappe_index(i); return; } @@ -1404,21 +1368,21 @@ static void chaine_suivante() { if (!recording()) { - int nouvelle = chaineCourante + 1; + int nouvelle = ixChaineCourante + 1; if (nouvelle >= (int)Canaux.size()) nouvelle=0; zappe_index(nouvelle); } else { // faut trouver une chaîne après avec la même fréq - for (int i = chaineCourante + 1; i < (int)Canaux.size(); i++) { - if (Canaux[i].frequence == Canaux[chaineCourante].frequence) { + for (int i = ixChaineCourante + 1; i < (int)Canaux.size(); i++) { + if (Canaux[i].frequence == Canaux[ixChaineCourante].frequence) { zappe_index(i); return; } } - for (int i = 0; i= 0 && Canaux[index_chaine].frequence == Canaux[chaineCourante].frequence) - zappe_index(index_chaine); - } - nouvelleChaine = 0; + numeroChaineSaisi = 0; + + // La nouvelle chaîne doit évidemment être valide : + if (!ixChaine_ok(ixChaine)) + return; + + // Si enregistrement en cours, ne changer de chaîne que si on ne change pas de multiplex : + if (recording() && Canaux[ixChaine].frequence != Canaux[ixChaineCourante].frequence) + return; + + zappe_index(ixChaine); } static void mouse_move(WPARAM wParam, LPARAM lParam) @@ -1612,7 +1580,7 @@ static void do_osd(HDC hdc) { - if (chaineCourante >= 0) { + if (ixChaineCourante >= 0) { DWORD current = GetTickCount(); bool show_prog = current - last_zapping < DUREE_OSD; @@ -1716,7 +1684,7 @@ if (show_prog) { SetTextAlign(hdc, TA_RIGHT); - Chaine & ch = Canaux[chaineCourante]; + Chaine & ch = Canaux[ixChaineCourante]; TextOutA(hdc, rect.right-10, rect.top, ch.nom, (int)strlen(ch.nom)); @@ -1727,14 +1695,14 @@ // Affiche les numéros saisis pour le choix des chaines en haut/droite if (show_chaine) { - if(nouvelleChaine > 256) { - nouvelleChaine = 0; + if (numeroChaineSaisi > 999) { + numeroChaineSaisi = 0; KillTimer(hMainWnd, TIMER_NUMBER); - } else if (nouvelleChaine > 0) { + } else if (numeroChaineSaisi > 0) { SetTextAlign(hdc, TA_RIGHT); char numeros[5]; - _itoa_s(nouvelleChaine, numeros, _countof(numeros), 10); + _itoa_s(numeroChaineSaisi, numeros, _countof(numeros), 10); //myprintf(L"Actualise la chaine: %d\t%S\n", nouvelleChaine, numeros); TextOutA(hdc, rect.right-10, rect.top, numeros, (int)strlen(numeros)); @@ -1789,7 +1757,7 @@ if (SUCCEEDED(hr)) { - NomFichierAvecDate nom_fichier(screenshots_dir, Canaux[chaineCourante].nom, "bmp"); + NomFichierAvecDate nom_fichier(screenshots_dir, Canaux[ixChaineCourante].nom, "bmp"); HANDLE file = nom_fichier.Create(); if (file != INVALID_HANDLE_VALUE) { @@ -1938,12 +1906,12 @@ break; case IDM_RECORD_CHANNEL_TS: - if (start_record_ts(chaineCourante)>=0) + if (start_record_ts(ixChaineCourante)>=0) update_record_menus(hMainWnd); break; case IDM_RECORD_CHANNEL_PS: - if (start_record_ps(chaineCourante, sonCourant)>=0) + if (start_record_ps(ixChaineCourante, ixSonCourant)>=0) update_record_menus(hMainWnd); break; @@ -1955,7 +1923,7 @@ #endif // #if USE_RECORD_STREAM case IDM_STOP_RECORD: - grab = getGrabberChaine(chaineCourante); + grab = getGrabberChaine(ixChaineCourante); if (grab>=0) { stop_record(grab); update_record_menus(hMainWnd); @@ -1963,9 +1931,7 @@ break; case IDM_DELAYED_STOP: - ShowCursor(TRUE); - DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_DELAYED_STOP), hMainWnd, DelayedStopDialogProc); - ShowCursor(FALSE); + delayed_stop_dialog(); break; case IDM_FULLSCREEN: { @@ -2073,7 +2039,7 @@ zappe_index(wID); } else if (wID>=500 && wID<600) { // cas changement piste - switch_audio(sonCourant, wID-500); + switch_audio(ixSonCourant, wID-500); update_menus(hMainWnd, 1, update_pistes_menu); } } @@ -2250,8 +2216,8 @@ return -1; if (suspend_minimized) { rebranche(); - change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire - zappe_index(chaineCourante); + change_frequence(Canaux[ixChaineCourante].frequence); // Vérifier si nécessaire + zappe_index(ixChaineCourante); } ShowWindow(hWnd, SW_SHOW); ShowWindow(hWnd, SW_RESTORE); @@ -2388,8 +2354,8 @@ return -1; if (suspend_minimized) { rebranche(); - change_frequence(Canaux[chaineCourante].frequence); // Vérifier si nécessaire - zappe_index(chaineCourante); + change_frequence(Canaux[ixChaineCourante].frequence); // Vérifier si nécessaire + zappe_index(ixChaineCourante); } myprintf(L"WM_SYSCOMMAND restore\n"); if (minimize_system_tray) @@ -2418,7 +2384,7 @@ break; case WM_USER+1: - zappe_index(chaineCourante); + zappe_index(ixChaineCourante); break; default: @@ -2593,6 +2559,10 @@ // Comme marqué, on crée la barre de status de la fenêtre create_status_bar(); + // Lecture du fichier des chaînes (avant celle de la programmation, car on peut avoir besoin de la liste + // des chaînes dans celle-ci). + lit_chaines(); + // Chargement et purge de la liste des programmes init_programmation(); @@ -2623,7 +2593,7 @@ set_priority(configPriority); // Ajustements de l'état de départ de la fenêtre : - if (lit_chaines()!=0 || Canaux.size()==0) { + if (Canaux.size()==0) { // Pas question d'utiliser un état de fenêtre sauvegardé dans la config // ou de tourner en mode minimisé si aucune chaîne n'a encore été détectée cmd_minimize = false; @@ -2679,8 +2649,8 @@ int nbr_chaines = Canaux.size(); - if (chaineCourante>=0 && chaineCourante=0 && ixChaineCourante freq_scan; -extern WORD nouvelleChaine; +extern WORD sidChaineConfig; // SID chaîne récupéré dans 'config.ini' extern HINSTANCE hAppInstance; extern HWND hMainWnd; @@ -40,11 +40,6 @@ extern HICON hPrgIcon; // Icône normale du programme extern HICON hRecIcon; // Icône utilisée en mode enregistrement -DWORD get_priority(); - -void zappe_index(int index_chaine); -void zappe_chaine(WORD numero_chaine); - extern wchar_t filtreMPEG2[256]; extern wchar_t filtreAudio[256]; extern wchar_t filtreAc3[256]; @@ -76,9 +71,6 @@ // Répertoire pour la sauvegarde des paramètres (Dossier App Data) extern wchar_t pouchindir_conf[MAX_PATH]; -// Récupération de l'état de la fenêtre : -EtatsFenetre etat_fenetre(HWND hWnd); - #if LOG_DSHOW extern HANDLE logFile; #endif // #if LOG_DSHOW @@ -92,3 +84,17 @@ #define TIMER_RECORD_END_BASE 130 #define TIMER_RECORD_END_FIN (TIMER_RECORD_END_BASE + NB_MAX_ENREG + 1) #define TIMER_UPDATE (TIMER_RECORD_END_FIN + 1) + +DWORD get_priority(); + +void zappe_index(int ixChaine); + +/** + * Restauration d'une chaîne sauvegardée par SID. + * Si le SID n'est pas valide, on utilise la première de la liste. + * Retourne 'true' si succès, 'false' si la liste est vide. + **/ +bool restaure_chaine(WORD sidChaine); + +// Récupération de l'état de la fenêtre : +EtatsFenetre etat_fenetre(HWND hWnd); Modified: trunk/parse.cpp =================================================================== --- trunk/parse.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/parse.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -431,22 +431,6 @@ } } -void trie_chaines() -{ - int nbChaines = (int)Canaux.size(); - - // un vieux tri bulles :o - for (int i = 0; i Canaux[j].numero_nit) { - Chaine temp = Canaux[i]; - Canaux[i] = Canaux[j]; - Canaux[j] = temp; - } - } - } -} - /* Network Information section (NIT) Syntax No. of bits Offset @@ -601,9 +585,9 @@ LPBYTE(plchent)end(); plchent++ ) { chIDs.SID = plchent->sid(); - chIDs.numero_nit = plchent->logical_channel_number(); + chIDs.numeroChaine = plchent->logical_channel_number(); //myprintf(L"parse_nit: ONID=%i, TSID=%i, SID=%i, numero=%i\n", - // chIDs.ONID, chIDs.TSID, chIDs.SID, chIDs.numero_nit); + // chIDs.ONID, chIDs.TSID, chIDs.SID, chIDs.numeroChaine); chaineIDs.push_back(chIDs); } } @@ -766,7 +750,7 @@ for(std::vector::iterator itt=chaineIDs.begin(); itt!=chaineIDs.end(); itt++) { if (canal.ONID==itt->ONID && canal.TSID==itt->TSID && canal.SID==itt->SID) - canal.numero_nit = itt->numero_nit; + canal.numeroChaine = itt->numeroChaine; } } } Modified: trunk/parse.h =================================================================== --- trunk/parse.h 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/parse.h 2007-10-20 13:36:58 UTC (rev 98) @@ -35,8 +35,6 @@ bool tune(HWND hwndDlg, const Frequence & freq, bool * stopping); -void trie_chaines(); - // Contient les informations récupérées dans la NIT pour définir les numéros des chaînes : extern std::vector chaineIDs; Modified: trunk/pmtfilter.cpp =================================================================== --- trunk/pmtfilter.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/pmtfilter.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -64,7 +64,7 @@ parse_pmt((const PMT *)p, max, pmt/*, false*/); - Chaine & chaine = Canaux[chaineCourante]; + Chaine & chaine = Canaux[ixChaineCourante]; bool change=0; Modified: trunk/record.cpp =================================================================== --- trunk/record.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/record.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -34,12 +34,12 @@ Enregistrement enregistrements_actuels[NB_MAX_ENREG]; -void Enregistrement::start(int index_chaine, ISampleGrabberCB * pCallback, ApresEnregistrement apr) +void Enregistrement::start(int ixChaine, ISampleGrabberCB * pCallback, ApresEnregistrement apr) { stop(); // précaution - if (pSample && pCallback && index_chaine!=-1) { + if (pSample && pCallback && ixChaine!=-1) { pSample->SetCallback(pCallback, 0); - chaine = index_chaine; + indexChaine = ixChaine; apres = apr; } } @@ -48,9 +48,9 @@ { ApresEnregistrement apr = apres; - if (pSample && chaine!=-1) + if (pSample && indexChaine!=-1) pSample->SetCallback(NULL, 0); - chaine = -1; + indexChaine = -1; apres = apr_rien; return apr; } @@ -106,21 +106,22 @@ } /** - * Chercher l'index des informations concernant la chaine de numéro 'chaine' si celle-ci est - * en cours d'enregistrement. Retourne -1 si elle ne l'est pas. + * Chercher l'index (dans 'enregistrements_actuels') des informations concernant + * la chaine d'index 'ixChaine' si celle-ci est en cours d'enregistrement. + * Retourne -1 si elle ne l'est pas. **/ -int getGrabberChaine(int chaine) +int getGrabberChaine(int ixChaine) { for (int i=0; i=0) { - const Chaine & canal = Canaux[index_chaine]; + const Chaine & canal = Canaux[ixChaine]; NomFichierAvecDate nom_fichier(video_dir, canal.nom, "ts"); int video = canal.video_pid ? canal.video_pid : canal.mpeg4_pid; @@ -171,25 +160,28 @@ canal.autre, canal.nb_autre); - enregistrements_actuels[grab].start(index_chaine, pCallback); + enregistrements_actuels[grab].start(ixChaine, pCallback); } return grab; } // Démarrage d'un enregistrement en mode PS, pour la chaîne dont l'index -// est égal à 'index_chaine', avec 'index_son' comme piste son +// est égal à 'ixChaine', avec 'ixSon' comme piste son // Le tuner est supposé être déjà syntonisé sur la bonne fréquence // Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. // TODO : retirer la restriction sur la syntonisation -// TODO : faire en sorte que toutes les pistes son soient enregistrées si 'index_son'=-1 -int start_record_ps(int index_chaine, int index_son) +// TODO : faire en sorte que toutes les pistes son soient enregistrées si 'ixSon'=-1 +int start_record_ps(int ixChaine, int ixSon) { + if (!ixChaine_ok(ixChaine)) + return -1; + int grab = getFreeGrabber(); if (grab>=0) { - const Chaine & canal = Canaux[index_chaine]; + const Chaine & canal = Canaux[ixChaine]; NomFichierAvecDate nom_fichier(video_dir, canal.nom, "mpg"); int video = canal.video_pid ? canal.video_pid : canal.mpeg4_pid; - int son = canal.son[index_son].pid; + int son = canal.son[ixSon].pid; ISampleGrabberCB * pCallback = new CSampleGrabber( @@ -197,7 +189,7 @@ video, son); - enregistrements_actuels[grab].start(index_chaine, pCallback); + enregistrements_actuels[grab].start(ixChaine, pCallback); } return grab; } @@ -205,7 +197,7 @@ #if USE_RECORD_STREAM // Démarrage d'un enregistrement global du multiplex. // Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. -// TODO : ajouter un paramètre (par ex. index_chaine) pour que soit préalablement syntonisé le multiplex +// TODO : ajouter un paramètre (par ex. ixChaine) pour que soit préalablement syntonisé le multiplex // correspondant à la chaîne désignée. int start_record_stream() { Modified: trunk/record.h =================================================================== --- trunk/record.h 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/record.h 2007-10-20 13:36:58 UTC (rev 98) @@ -30,17 +30,17 @@ #include "recprog.h" class Enregistrement { - int chaine; // Numéro de la chaine enregistrée - ApresEnregistrement apres; // Ce que doit faire Pouchin TV Mod une fois l'enregistrement terminé + int indexChaine; // Numéro de la chaine enregistrée + ApresEnregistrement apres; // Ce que doit faire Pouchin TV Mod une fois l'enregistrement terminé ISampleGrabber * pSample; public: // // Mini-constructeur : - Enregistrement() : chaine(-1), apres(apr_rien), pSample(NULL) {} + Enregistrement() : indexChaine(-1), apres(apr_rien), pSample(NULL) {} // - bool recording() const {return chaine >=0 ;} - bool isChannel(int index_chaine) const {return chaine == index_chaine;} - void start(int index_chaine, ISampleGrabberCB * pCallback, ApresEnregistrement apr = apr_rien); + bool recording() const {return indexChaine >=0 ;} + bool isChannel(int ixChaine) const {return indexChaine == ixChaine;} + void start(int ixChaine, ISampleGrabberCB * pCallback, ApresEnregistrement apr = apr_rien); void query(IBaseFilter * pGrabber); void free(); void setAfter(ApresEnregistrement apr) {apres = apr;} @@ -64,38 +64,39 @@ void stop_all_records(); /** - * Chercher l'index des informations concernant la chaine de numéro 'chaine' si celle-ci est - * en cours d'enregistrement. Retourne -1 si elle ne l'est pas. + * Chercher l'index (dans 'enregistrements_actuels') des informations concernant + * la chaine d'index 'ixChaine' si celle-ci est en cours d'enregistrement. + * Retourne -1 si elle ne l'est pas. **/ -int getGrabberChaine(int chaine); +int getGrabberChaine(int ixChaine); /** - * Chercher un poste d'enregistrement libre. Retourne l'index de ce poste, ou bien - * -1 s'il n'y en a plus de disponible. + * Chercher un index d'enregistrement libre dans 'enregistrements_actuels'. + * Retourne l'index de ce poste, ou bien -1 s'il n'y en a plus de disponible. **/ int getFreeGrabber(); -// Démarrage d'un enregistrement en mode TS, pour la chaîne dont l'index est égal à index_chaine +// Démarrage d'un enregistrement en mode TS, pour la chaîne dont l'index est égal à ixChaine // Le tuner est supposé être déjà syntonisé sur la bonne fréquence // Toutes les pistes audio sont enregistrées // Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. // TODO : retirer la restriction sur la syntonisation -// TODO : ajouter le paramètre 'index_son' pour choisir entre l'enregistrement d'une piste audio donnée, +// TODO : ajouter le paramètre 'ixSon' pour choisir entre l'enregistrement d'une piste audio donnée, // ou bien toutes les pistes audio si -1 -int start_record_ts(int index_chaine); +int start_record_ts(int ixChaine); // Démarrage d'un enregistrement en mode PS, pour la chaîne dont l'index -// est égal à 'index_chaine', avec 'index_son' comme piste son +// est égal à 'ixChaine', avec 'ixSon' comme piste son // Le tuner est supposé être déjà syntonisé sur la bonne fréquence // Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. // TODO : retirer la restriction sur la syntonisation -// TODO : faire en sorte que toutes les pistes son soient enregistrées si 'index_son'=-1 -int start_record_ps(int index_chaine, int index_son); +// TODO : faire en sorte que toutes les pistes son soient enregistrées si 'ixSon'=-1 +int start_record_ps(int ixChaine, int ixSon); #if USE_RECORD_STREAM // Démarrage d'un enregistrement global du multiplex. // Retourne l'index dans la table des enregistrements, ou bien -1 si aucun enregistrement n'a pu démarrer. -// TODO : ajouter un paramètre (par ex. index_chaine) pour que soit préalablement syntonisé le multiplex +// TODO : ajouter un paramètre (par ex. ixChaine) pour que soit préalablement syntonisé le multiplex // correspondant à la chaîne désignée. int start_record_stream(); #endif Modified: trunk/recprog.cpp =================================================================== --- trunk/recprog.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/recprog.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -47,15 +47,15 @@ static wchar_t mdp[256] = L""; /** - * On passe un numéro de chaine en paramètre, + * On passe un SID de chaine en paramètre, * et on retourne la fréquence du multiplex correspondant **/ -static long getFrequence(WORD chaine) +static long getFrequence_par_sid(WORD sidChaine) { - int index_chaine = trouve_chaine(chaine); + int ixChaine = trouve_chaine_par_sid(sidChaine); - if (index_chaine >= 0) - return Canaux[index_chaine].frequence; + if (ixChaine >= 0) + return Canaux[ixChaine].frequence; return -1; } @@ -77,11 +77,11 @@ **/ bool Programme::verifie() const { - int index = trouve_chaine(chaine); + int ixChaine = trouve_chaine_par_sid(sidChaine); SYSTEMTIME time; wchar_t buffer[256]; - if (index<0) { + if (ixChaine<0) { erreur(L"La chaîne est incorrecte"); return false; } @@ -103,6 +103,8 @@ return false; } + const Chaine & canal = Canaux[ixChaine]; + for(UINT i = 0; i < Programmes.size(); i++) { const Programme & prog_verif = Programmes[i]; @@ -113,11 +115,11 @@ // S'il y a chevauchement des horaires, vérifie que le programme est sur le même multiplex : if (DiffTime(prog_verif.debut, fin) <= 0 && DiffTime(prog_verif.fin, debut) >= 0 && - getFrequence(prog_verif.chaine) != Canaux[index].frequence + getFrequence_par_sid(prog_verif.sidChaine) != canal.frequence ) { swprintf_s(buffer, _countof(buffer), - L"Chevauchement des horaires avec \"%S\", qui ne partage pas le même multiplex !", - prog_verif.nom); + L"Chevauchement des horaires avec \"%S\" sur %S, qui ne partage pas le même multiplex !", + prog_verif.nom, canal.nom); erreur(buffer); return false; } @@ -406,16 +408,86 @@ result.wMilliseconds = 0; } +void SetCtlTimeDate(HWND hDlg, int dateID, int timeID, const SYSTEMTIME & value) +{ + SendDlgItemMessage(hDlg, dateID, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&value); + SendDlgItemMessage(hDlg, timeID, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&value); +} + +static void remplit_liste_programmes(HWND hdlg, int lvID) +{ + int nbProgrammes = (int)Programmes.size(); + + LVITEMA item; + memset(&item, 0, sizeof(item)); + + item.mask = LVIF_TEXT; + + char buffer[64]; + + for(item.iItem=0; item.iItem(prog.nom); + SendDlgItemMessage(hdlg, lvID, LVM_INSERTITEMA, 0, (LPARAM)&item); + + item.iSubItem = 1; + sprintf_s(buffer, _countof(buffer), "%s", Canaux[ixChaine].nom); + item.pszText = buffer; + SendDlgItemMessage(hdlg, lvID, LVM_SETITEMA, 0, (LPARAM)&item); + + item.iSubItem = 2; + sprintf_s(buffer, _countof(buffer), "%02i:%02i:%02i %02i/%02i/%04i", + prog.debut.wHour, prog.debut.wMinute, prog.debut.wSecond, + prog.debut.wDay, prog.debut.wMonth, prog.debut.wYear); + item.pszText = buffer; + SendDlgItemMessage(hdlg, lvID, LVM_SETITEMA, 0, (LPARAM)&item); + + item.iSubItem = 3; + sprintf_s(buffer, _countof(buffer), "%02i:%02i:%02i %02i/%02i/%04i", + prog.fin.wHour, prog.fin.wMinute, prog.fin.wSecond, + prog.fin.wDay, prog.fin.wMonth, prog.fin.wYear); + item.pszText = buffer; + SendDlgItemMessage(hdlg, lvID, LVM_SETITEMA, 0, (LPARAM)&item); + } +} + /** + * Récupération de l'action "après enregistrement" selon l'état des deux cases à cocher + * qui lui sont dédiées. + **/ +static ApresEnregistrement GetCtlAfter(HWND hDlg, int powerID, int quitID) +{ + if (IsDlgButtonChecked(hDlg, powerID) == BST_CHECKED) + return apr_eteindrePC; + else if(IsDlgButtonChecked(hDlg, quitID) == BST_CHECKED) + return apr_quitter; + return apr_rien; +} + + +/** + * Mise à jour des cases à cocher correspondant à l'action "après enregistrement" + * selon le contenu de la variable 'after'. + **/ +static void SetCtlAfter(HWND hDlg, int powerID, int quitID, ApresEnregistrement after) { + CheckDlgButton(hDlg, powerID, (after==apr_eteindrePC) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, quitID, (after==apr_rien) ? BST_UNCHECKED : BST_CHECKED); +} + +/** * Récupère les données de l'enregistrement dans la fenêtre, * et l'ajoute aux tâches programmées. Demande la suppression de la tâche plannifiée si besoin est... **/ static int add_programme(HWND hwndDlg, int sel, std::vector&taches_supprimer) { char buffer[256]; - int index, i; - //memset(buffer, 0, 127); - //SYSTEMTIME time_buffer; + int i; Programme prog; ZeroMemory(&prog, sizeof(Programme)); @@ -425,23 +497,23 @@ buffer[lsiz] = 0; strcpy_s(prog.nom, _countof(prog.nom), buffer); - index = (int)SendDlgItemMessage(hwndDlg, IDC_CHANNEL, CB_GETCURSEL, 0, 0); - prog.chaine = Canaux[index].numero_nit; + int ixChaine = (int)SendDlgItemMessage(hwndDlg, IDC_CHANNEL, CB_GETCURSEL, 0, 0); + if (!ixChaine_ok(ixChaine)) + return 1; + + const Chaine & canal = Canaux[ixChaine]; + + prog.numeroChaine = canal.numeroChaine; + prog.sidChaine = canal.SID; + GetCtlTimeDate(hwndDlg, IDC_DATE_START, IDC_TIME_START, prog.debut); GetCtlTimeDate(hwndDlg, IDC_DATE_END, IDC_TIME_END, prog.fin); prog.methode = (MethodeEnregistrement)SendDlgItemMessage(hwndDlg, IDC_METHOD, CB_GETCURSEL, 0, 0); prog.audio = (AudioMode)SendDlgItemMessage(hwndDlg, IDC_AUDIO, CB_GETCURSEL, 0, 0); + prog.after = GetCtlAfter(hwndDlg, IDC_AFTER_POWEROFF, IDC_AFTER); - if(IsDlgButtonChecked(hwndDlg, IDC_AFTER_POWEROFF) == BST_CHECKED) { - prog.after = apr_eteindrePC; - } else if(IsDlgButtonChecked(hwndDlg, IDC_AFTER) == BST_CHECKED) { - prog.after = apr_quitter; - } else { - prog.after = apr_rien; - } - // Ajoute l'indicatif pour la répétition for (i=0; i<7; i++) { if (IsDlgButtonChecked(hwndDlg, IDC_REP_BASE+i) == BST_CHECKED) @@ -474,13 +546,7 @@ Programmes.insert(Programmes.begin() + sel, prog); - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_DELETEALLITEMS, 0, 0); - remplit_liste_programmes(hwndDlg, IDC_LIST_PROGRAMMES); - LVITEMA item; - item.stateMask = LVIS_SELECTED; - item.state = LVIS_SELECTED; - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_SETITEMSTATE, sel, (LPARAM)&item); - + PostMessage(hwndDlg, WM_APP, 0, 0); // Reconstruction de la liste return 0; } @@ -498,93 +564,92 @@ switch (uMsg) { - case WM_INITDIALOG: { + case WM_INITDIALOG: { - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); - LVCOLUMN colonne; - memset(&colonne, 0, sizeof(LVCOLUMN)); + static const struct Tab_cols { + LPCWSTR nom; + int taille; + } t_cols[] = { + {L"Nom", 120}, + {L"Chaîne", 88}, + {L"Début", 118}, + {L"Fin", 118} + }; - colonne.mask = LVCF_TEXT|LVCF_WIDTH; + for (i=0; i<_countof(t_cols); i++) { + const Tab_cols & col = t_cols[i]; + LVCOLUMN colonne = { + LVCF_TEXT|LVCF_WIDTH, // mask + 0, // fmt + col.taille, // cx + const_cast(col.nom) // pszText + // le reste à zéro (implicite) + }; - colonne.cx = 100; - colonne.pszText = L"Nom"; - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 0, (LPARAM)&colonne); + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, i, (LPARAM)&colonne); + } - colonne.cx = 50; - colonne.pszText = L"Chaîne"; - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 1, (LPARAM)&colonne); + remplit_liste_programmes(hwndDlg, IDC_LIST_PROGRAMMES); - colonne.cx = 140; - colonne.pszText = L"Début"; - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 2, (LPARAM)&colonne); + SYSTEMTIME time; - colonne.cx = 140; - colonne.pszText = L"Fin"; - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_INSERTCOLUMN, 3, (LPARAM)&colonne); + GetLocalTime(&time); - remplit_liste_programmes(hwndDlg, IDC_LIST_PROGRAMMES); + time.wSecond = 0; + time.wMilliseconds = 0; + SetCtlTimeDate(hwndDlg, IDC_DATE_START, IDC_TIME_START, time); + SetCtlTimeDate(hwndDlg, IDC_DATE_END, IDC_TIME_END, time); - SYSTEMTIME time; + int nbchaines = (int)Canaux.size(); - GetLocalTime(&time); + for (i=0; i= 0 && ((LPNMHDR)lParam)->code == NM_CLICK) { + case WM_NOTIFY: + switch (wParam) { + case IDC_LIST_PROGRAMMES: + if (sel >= 0 && ((LPNMHDR)lParam)->code == NM_CLICK) { const Programme & prog = Programmes[sel]; SendDlgItemMessageA(hwndDlg, IDC_NAME, WM_SETTEXT, 0, (LPARAM)prog.nom); - int index = trouve_chaine(prog.chaine); + int ixChaine = trouve_chaine_par_sid(prog.sidChaine); - SendDlgItemMessage(hwndDlg, IDC_CHANNEL, CB_SETCURSEL, index, 0); + SendDlgItemMessage(hwndDlg, IDC_CHANNEL, CB_SETCURSEL, ixChaine, 0); - SendDlgItemMessage(hwndDlg, IDC_DATE_START, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&prog.debut); - SendDlgItemMessage(hwndDlg, IDC_TIME_START, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&prog.debut); + SetCtlTimeDate(hwndDlg, IDC_DATE_START, IDC_TIME_START, prog.debut); + SetCtlTimeDate(hwndDlg, IDC_DATE_END, IDC_TIME_END, prog.fin); - SendDlgItemMessage(hwndDlg, IDC_DATE_END, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&prog.fin); - SendDlgItemMessage(hwndDlg, IDC_TIME_END, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&prog.fin); - SendDlgItemMessage(hwndDlg, IDC_METHOD, CB_SETCURSEL, prog.methode, 0); SendDlgItemMessage(hwndDlg, IDC_AUDIO, CB_SETCURSEL, prog.audio, 0); - CheckDlgButton(hwndDlg, IDC_AFTER_POWEROFF, - (prog.after==apr_eteindrePC) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AFTER, - (prog.after==apr_rien) ? BST_UNCHECKED : BST_CHECKED); + SetCtlAfter(hwndDlg, IDC_AFTER_POWEROFF, IDC_AFTER, prog.after); + CheckDlgButton(hwndDlg, IDC_TACHE, prog.tache ? BST_CHECKED : BST_UNCHECKED); @@ -596,97 +661,137 @@ CheckDlgButton(hwndDlg, IDC_REP_BASE+i, prog.repetition[i]); return TRUE; - } else - return FALSE; } + } + break; + case IDC_DATE_START: + case IDC_TIME_START: + if (((LPNMHDR)lParam)->code == DTN_DATETIMECHANGE) { + SYSTEMTIME debut; + SYSTEMTIME fin; - case WM_COMMAND: - switch(LOWORD(wParam)) { + GetCtlTimeDate(hwndDlg, IDC_DATE_START, IDC_TIME_START, debut); + GetCtlTimeDate(hwndDlg, IDC_DATE_END, IDC_TIME_END, fin); + if (DiffTime(debut, fin) > 0) + SetCtlTimeDate(hwndDlg, IDC_DATE_END, IDC_TIME_END, debut); + } + break; + case IDC_DATE_END: + case IDC_TIME_END: + if (((LPNMHDR)lParam)->code == DTN_DATETIMECHANGE) { + SYSTEMTIME debut; + SYSTEMTIME fin; - case IDC_METHOD: - if (HIWORD(wParam) == CBN_SELCHANGE) { - int index = (int)SendDlgItemMessage(hwndDlg, IDC_METHOD, CB_GETCURSEL, 0, 0); - if (index == 0 || index ==2){ - EnableWindow(GetDlgItem( hwndDlg, IDC_AUDIO), FALSE); - } - if (index == 1) { - EnableWindow(GetDlgItem( hwndDlg, IDC_AUDIO), TRUE); - } - } - return TRUE; + GetCtlTimeDate(hwndDlg, IDC_DATE_START, IDC_TIME_START, debut); + GetCtlTimeDate(hwndDlg, IDC_DATE_END, IDC_TIME_END, fin); + if (DiffTime(debut, fin) > 0) + SetCtlTimeDate(hwndDlg, IDC_DATE_START, IDC_TIME_START, fin); + } + } + return FALSE; + case WM_COMMAND: + switch(LOWORD(wParam)) { - case IDC_REMOVE: - if(sel != -1) { - SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_DELETEITEM, sel, 0); - Programme &prog = Programmes[sel]; - - if (prog.tache != planif_sans) { - char *tache=new char[strlen(prog.nom)+1]; - strcpy_s(tache, strlen(prog.nom)+1, prog.nom); - taches_supprimer.push_back(tache); - } - Programmes.erase(Programmes.begin() + sel); + case IDC_METHOD: + if (HIWORD(wParam) == CBN_SELCHANGE) { + int index = (int)SendDlgItemMessage(hwndDlg, IDC_METHOD, CB_GETCURSEL, 0, 0); + if (index == 0 || index ==2){ + EnableWindow(GetDlgItem( hwndDlg, IDC_AUDIO), FALSE); } + if (index == 1) { + EnableWindow(GetDlgItem( hwndDlg, IDC_AUDIO), TRUE); + } + } + return TRUE; - return TRUE; - case IDC_MODIFY: - if(sel != -1) { - Programme prog = Programmes[sel]; - Programmes.erase(Programmes.begin() + sel); - if(add_programme(hwndDlg, sel, taches_supprimer)) - Programmes.insert(Programmes.begin() + sel, prog); - return TRUE; - }else return FALSE; + case IDC_REMOVE: + if(sel != -1) { + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_DELETEITEM, sel, 0); + Programme &prog = Programmes[sel]; - case IDC_ADD: - { - int n = (int)SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_GETITEMCOUNT, 0, 0); - add_programme(hwndDlg, (sel + n + 1) % (n + 1), taches_supprimer); - return TRUE; + if (prog.tache != planif_sans) { + char *tache=new char[strlen(prog.nom)+1]; + strcpy_s(tache, strlen(prog.nom)+1, prog.nom); + taches_supprimer.push_back(tache); } + Programmes.erase(Programmes.begin() + sel); + } - case IDOK: - // sauvegarder le changement + return TRUE; - supprimer_taches(taches_supprimer); - ajouter_taches(hwndDlg); - sauve_programmes(); + case IDC_MODIFY: + if (sel != -1) { + Programme prog = Programmes[sel]; + Programmes.erase(Programmes.begin() + sel); + if(add_programme(hwndDlg, sel, taches_supprimer)) + Programmes.insert(Programmes.begin() + sel, prog); + return TRUE; + } + return FALSE; - // ... passage à travers - case IDCANCEL: + case IDC_ADD: { + int n = (int)SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_GETITEMCOUNT, 0, 0); + add_programme(hwndDlg, (sel + n + 1) % (n + 1), taches_supprimer); + return TRUE; } - lit_programmes(); - set_timer_record(); - DestroyWindow(hwndDlg); - return TRUE; + case IDOK: + // sauvegarder le changement - case IDC_AFTER_POWEROFF: - // Coche le bouton arrêtant PouchinTV si on a demandé l'arrêt de l'ordinateur - if (IsDlgButtonChecked(hwndDlg, IDC_AFTER_POWEROFF) == BST_CHECKED) - CheckDlgButton(hwndDlg, IDC_AFTER, BST_CHECKED); - return TRUE; + supprimer_taches(taches_supprimer); + ajouter_taches(hwndDlg); + sauve_programmes(); - case IDC_AFTER: - // Décoche le bouton arrêtant le PC si on ne souhaite pas arrêter PouchinTV - if (IsDlgButtonChecked(hwndDlg, IDC_AFTER) == BST_UNCHECKED) - CheckDlgButton(hwndDlg, IDC_AFTER_POWEROFF, BST_UNCHECKED); - return TRUE; - } - return FALSE; + // ... passage à travers + case IDCANCEL: - case WM_CLOSE: lit_programmes(); set_timer_record(); DestroyWindow(hwndDlg); return TRUE; - case WM_NCDESTROY: - hRecordDlg = NULL; - ShowCursor(FALSE); // Rétablit la disparition temporisée du curseur - return FALSE; - default: - return FALSE; + case IDC_AFTER_POWEROFF: + // Coche le bouton arrêtant PouchinTV si on a demandé l'arrêt de l'ordinateur + if (IsDlgButtonChecked(hwndDlg, IDC_AFTER_POWEROFF) == BST_CHECKED) + CheckDlgButton(hwndDlg, IDC_AFTER, BST_CHECKED); + return TRUE; + + case IDC_AFTER: + // Décoche le bouton arrêtant le PC si on ne souhaite pas arrêter PouchinTV + if (IsDlgButtonChecked(hwndDlg, IDC_AFTER) == BST_UNCHECKED) + CheckDlgButton(hwndDlg, IDC_AFTER_POWEROFF, BST_UNCHECKED); + return TRUE; + } + return FALSE; + + case WM_CLOSE: + lit_programmes(); + set_timer_record(); + DestroyWindow(hwndDlg); + return TRUE; + + case WM_NCDESTROY: + hRecordDlg = NULL; + ShowCursor(FALSE); // Rétablit la disparition temporisée du curseur + return FALSE; + + case WM_APP: { + // Reconstruction de la liste des enregistrements programmés après changement : + LVITEM item = { + 0, // mask + 0, // iItem + 0, // iSubItem + LVIS_SELECTED, // state + LVIS_SELECTED // stateMask + }; + + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_DELETEALLITEMS, 0, 0); + remplit_liste_programmes(hwndDlg, IDC_LIST_PROGRAMMES); + SendDlgItemMessage(hwndDlg, IDC_LIST_PROGRAMMES, LVM_SETITEMSTATE, sel, (LPARAM)&item); + return TRUE; } + + default: + return FALSE; } } @@ -716,6 +821,63 @@ return false; } +static INT_PTR CALLBACK DelayedStopDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { + SYSTEMTIME time; + UINT delayed; + int grab; + + switch (uMsg) { + case WM_INITDIALOG: + GetLocalTime(&time); + + time.wHour = 0; + time.wMinute = 0; + time.wSecond = 0; + time.wMilliseconds = 0; + SendDlgItemMessage(hwndDlg, IDC_DELAYED_STOP, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&time); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDOK: + grab = getGrabberChaine(ixChaineCourante); + if (grab>=0) { + enregistrements_actuels[grab].setAfter(GetCtlAfter(hwndDlg, IDC_AFTER_POWEROFF, IDC_AFTER)); + KillTimer(hMainWnd, TIMER_RECORD_END_BASE+grab); + SendDlgItemMessage(hwndDlg, IDC_DELAYED_STOP, DTM_GETSYSTEMTIME, 0, (LPARAM)&time); + delayed = ((time.wHour*60 + time.wMinute)*60 + time.wSecond)*1000; + + SetTimer(hMainWnd, TIMER_RECORD_END_BASE+grab, delayed, NULL); + } + case IDCANCEL: + EndDialog(hwndDlg, 0); + return TRUE; + } + // ... + default: + return FALSE; + } +} + +/** + * Appel du dialogue de fin d'enregistrement retardée. + **/ +void delayed_stop_dialog() +{ + ShowCursor(TRUE); + DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_DELAYED_STOP), hMainWnd, DelayedStopDialogProc); + ShowCursor(FALSE); +} + +/** + * Fonction à appeler en cas de changement externe de la liste des enregistrements programmés. + **/ +void update_record_list() +{ + if (hRecordDlg) + PostMessage(hRecordDlg, WM_APP, 0, 0); // Reconstruction de la liste +} + // Trouver la piste audio la mieux adaptée au choix de l'utilisateur lors de la programmation : int selection_son(const un_son * sons, int nb_son, AudioMode audio) { @@ -751,39 +913,39 @@ Programme & prog = Programmes[next_record]; // Description de l'enregistrement à effectuer // Chercher l'index de la chaîne dont le numéro NIT correspond à celui demandé pour // l'enregistrement : - int index = trouve_chaine(prog.chaine); + int ixChaine = trouve_chaine_par_sid(prog.sidChaine); - if (index<0) + if (ixChaine<0) return -1; // si on n'en a pas trouvé - const Chaine & canal = Canaux[index]; + const Chaine & canal = Canaux[ixChaine]; // // Vérifier qu'on peut enregistrer : aucun enregistrement ne doit être déjà en cours, ou // bien l'enregistrement en cours doit concerner le même multiplex. - long frequence_courante = Canaux[chaineCourante].frequence; + long frequence_courante = Canaux[ixChaineCourante].frequence; if (recording() && canal.frequence != frequence_courante) return -1; // si on ne peut pas enregistrer if (canal.frequence != frequence_courante) { change_frequence(canal.frequence); - chaineCourante = index; - sonCourant = 0; + ixChaineCourante = ixChaine; + ixSonCourant = 0; } if (!IsMinimized(hMainWnd) && suspend_minimized) rebranche(); - int index_son = selection_son(canal.son, canal.nb_son, prog.audio); // utilisé seulement en PS pour le moment + int ixSon = selection_son(canal.son, canal.nb_son, prog.audio); // utilisé seulement en PS pour le moment int grab = -1; switch(prog.methode) { case meth_TS: - grab = start_record_ts(index); + grab = start_record_ts(ixChaine); break; case meth_PS: - grab = start_record_ps(index, index_son); + grab = start_record_ps(ixChaine, ixSon); break; #if USE_RECORD_STREAM case meth_multiplex: { Modified: trunk/recprog.h =================================================================== --- trunk/recprog.h 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/recprog.h 2007-10-20 13:36:58 UTC (rev 98) @@ -62,7 +62,8 @@ PlanificateurTache tache; SYSTEMTIME debut; SYSTEMTIME fin; - WORD chaine; + WORD numeroChaine; + WORD sidChaine; char nom[256]; // Tableau contenant les répétitions des enregistrements // 0: Dimanche, 1: Lundi, ...., 6: Samedi @@ -97,7 +98,16 @@ **/ bool is_record_dialog_message(MSG & msg); +/** + * Appel du dialogue de fin d'enregistrement retardée. + **/ +void delayed_stop_dialog(); +/** + * Fonction à appeler en cas de changement externe de la liste des enregistrements programmés. + **/ +void update_record_list(); + int do_record_start(); void do_record_stop(int grab); Modified: trunk/res.rc =================================================================== --- trunk/res.rc 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/res.rc 2007-10-20 13:36:58 UTC (rev 98) @@ -307,15 +307,19 @@ PUSHBUTTON "Annuler",IDCANCEL,89,54,54,14 END -IDD_DELAYED_STOP DIALOGEX 100, 100, 150, 75 +IDD_DELAYED_STOP DIALOGEX 100, 100, 180, 82 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Stopper l'enregistrement dans..." FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "",IDC_DELAYED_STOP,"SysDateTimePick32",DTS_UPDOWN | WS_TABSTOP | 0x8,51,16,48,12 - CTEXT "hh:mm:ss",IDC_STATIC,51,32,48,10 - DEFPUSHBUTTON "OK",IDOK,18,54,54,14 - PUSHBUTTON "Annuler",IDCANCEL,78,54,54,14 + CONTROL "",IDC_DELAYED_STOP,"SysDateTimePick32",DTS_UPDOWN | WS_TABSTOP | 0x8,65,7,48,12 + CTEXT "hh:mm:ss",IDC_STATIC,65,20,48,10 + CONTROL "Fermer Pouchin TV Mod après l'enregistrement",IDC_AFTER, + "Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,7,32,166,10 + CONTROL "Éteindre la lumière en partant",IDC_AFTER_POWEROFF, + "Button",BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,7,46,166,10 + DEFPUSHBUTTON "OK",IDOK,30,61,54,14 + PUSHBUTTON "Annuler",IDCANCEL,94,61,54,14 END IDD_CLOSE_CONFIRM DIALOGEX 100, 100, 150, 75 @@ -411,9 +415,9 @@ IDD_DELAYED_STOP, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 143 + RIGHTMARGIN, 173 TOPMARGIN, 7 - BOTTOMMARGIN, 68 + BOTTOMMARGIN, 75 END IDD_CLOSE_CONFIRM, DIALOG Modified: trunk/settings.cpp =================================================================== --- trunk/settings.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/settings.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -190,20 +190,6 @@ 0); } -static void restaure_chaine(WORD numero) -{ - trie_chaines(); // trie les chaînes par numéro - // - if (numero>0) { - // On essaye de remettre la même chaîne qu'avant, s'il y en avait une : - zappe_chaine(numero); - } else if (!Canaux.empty()) { - // S'il n'y en avait pas, on met la première de la liste ... - // ... laquelle a toutes les chances d'être TF1, mais bon ... :-( - zappe_index(0); - } -} - enum ScanState { ss_idle, @@ -223,7 +209,7 @@ } scanState = ss_idle; static bool stopping = false; static bool tuning = false; - static WORD numeroChaine = 0; + static WORD sidChaine = 0; static HWND hComboItem = NULL; static HWND hListItem = NULL; static HWND hStartBut = NULL; @@ -246,7 +232,7 @@ hInfoText = GetDlgItem(hDlg, IDC_SCAN_INFO); // Champ d'informations hProgBar = GetDlgItem(hDlg, IDC_SCAN_PROGRESS); // Barre de progression // - numeroChaine = chaineCourante>=0 ? Canaux[chaineCourante].numero_nit : 0; + sidChaine = ixChaine_ok(ixChaineCourante) ? Canaux[ixChaineCourante].SID : 0; remplit_combo_ville(hComboItem, nomVille); SendMessage(hComboItem, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)nomVille); // @@ -301,11 +287,11 @@ if (cancelCode==IDABORT) { zappe_index(-1); Canaux.clear(); - chaineCourante = -1; + ixChaineCourante = -1; // Si la recherche est annulée par l'utilisateur, alors on recharge // le fichier de chaînes précédent : lit_chaines(); - restaure_chaine(numeroChaine); + restaure_chaine(sidChaine); } EndDialog(hDlg, cancelCode); // IDCANCEL = annulé sans scan, // IDABORT = annulé après tentative de scan @@ -357,9 +343,12 @@ canal.video_pid!=0 ? (canal.mpeg4_pid!=0 ? 'X': '2') : (canal.mpeg4_pid!=0 ? '4': '?'); + char strnum[4] = "-"; // afficher '-' si zéro - swprintf_s(szTemp, _countof(szTemp), L"%u\t%s\t%S\t%u\t%S\t%c", canal.canal_no, szFreq, - *canal.groupe ? canal.groupe : "", canal.numero_nit, canal.nom, norme); + if (canal.numeroChaine > 0) + _itoa_s(canal.numeroChaine, strnum, _countof(strnum), 10); + swprintf_s(szTemp, _countof(szTemp), L"%u\t%s\t%S\t%S\t%S\t%c", canal.canal_no, szFreq, + *canal.groupe ? canal.groupe : "", strnum, canal.nom, norme); AddLineToList(hListItem, szTemp); } } @@ -401,7 +390,10 @@ AddLineToList(hListItem, msg_aucune); } else { do_init_vmr(); - restaure_chaine(numeroChaine); + trie_chaines(); // trier les chaînes par numéro + attribue_numeros(); // attribuer les numéros manquants + trie_chaines(); // trier à nouveau, les numéros attribués pouvant affecter l'ordre + restaure_chaine(sidChaine); } // // S'assurer que la barre de progression indique toujours ici le maximum, même si aucune Modified: trunk/trayicon.cpp =================================================================== --- trunk/trayicon.cpp 2007-10-16 22:10:38 UTC (rev 97) +++ trunk/trayicon.cpp 2007-10-20 13:36:58 UTC (rev 98) @@ -54,8 +54,8 @@ void MyNOTIFYICONDATA::set_tip() { - if (chaineCourante >= 0 && chaineCourante < (int)Canaux.size()) { - const Chaine & canal_courant = Canaux[chaineCourante]; + if (ixChaine_ok(ixChaineCourante)) { + const Chaine & canal_courant = Canaux[ixChaineCourante]; swprintf_s(szTip, _countof(szTip), L"%S - %S", canal_courant.nom, canal_courant.emis[0].nom); From pouchintv-svn at baysse.fr Sat Oct 20 22:04:32 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Sat, 20 Oct 2007 22:04:32 +0200 (CEST) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r99 - trunk Message-ID: <20071020200432.B2CEF5F2ED@mail.baysse.fr> Author: gingko Date: 2007-10-20 22:04:32 +0200 (Sat, 20 Oct 2007) New Revision: 99 Modified: trunk/settings.cpp Log: Correctif (le r?\195?\169pertoire des captures d'?\195?\169cran n'?\195?\169tait plus modifiable). Modified: trunk/settings.cpp =================================================================== --- trunk/settings.cpp 2007-10-20 13:36:58 UTC (rev 98) +++ trunk/settings.cpp 2007-10-20 20:04:32 UTC (rev 99) @@ -548,7 +548,7 @@ case PSN_APPLY: // Application des changements SendMessage(hVideoDirItem, WM_GETTEXT, _countof(video_dir), (LPARAM)video_dir); - SendMessage(hSshotDirItem, WM_SETTEXT, + SendMessage(hSshotDirItem, WM_GETTEXT, _countof(screenshots_dir), (LPARAM)screenshots_dir); return psn_result(hDlg, PSNRET_NOERROR); } From pouchintv-svn at baysse.fr Mon Oct 29 07:45:34 2007 From: pouchintv-svn at baysse.fr (pouchintv-svn at baysse.fr) Date: Mon, 29 Oct 2007 07:45:34 +0100 (CET) Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r100 - trunk Message-ID: <20071029064534.DC2395F2E9@mail.baysse.fr> Author: gingko Date: 2007-10-29 07:45:34 +0100 (Mon, 29 Oct 2007) New Revision: 100 Modified: trunk/canaux.ini Log: Mise ?\195?\160 jour de la liste des canaux selon les villes d'apr?\195?\168s les donn?\195?\169es CSA du 5 octobre 2007. Modified: trunk/canaux.ini =================================================================== --- trunk/canaux.ini 2007-10-20 20:04:32 UTC (rev 99) +++ trunk/canaux.ini 2007-10-29 06:45:34 UTC (rev 100) @@ -1,7 +1,7 @@ ; Fichier de mise à jour pour les canaux TNT de PouchinTV et ses mods ; -[Abbeville - La Motte] +[Abbeville - Maison Plaine] R1=29 R2=25 R3=33 @@ -15,8 +15,8 @@ R2=42 R3=45 R4=51 -R5=55 -R6=52 +R5=52 +R6=55 Offset=167 [Ajaccio - Baie d'Ajaccio] @@ -154,7 +154,16 @@ R6=46 Offset=167 -[Bar le Duc - Willeroncourt] +[Bar-le-Duc - Agglomération] +R1=33 +R2=47 +R3=57 +R4=44 +R5=60 +R6=63 +Offset=167 + +[Bar-le-Duc - Willeroncourt] R1=49 R2=47 R3=41 @@ -208,13 +217,13 @@ R6=63 Offset=167 -[Bordeaux - Bordeaux Est] -R1=23 -R2=59 -R3=62 -R4=44 -R5=41 -R6=30 +[Blois - Agglomération] +R1=34 +R2=38 +R3=63 +R4=48 +R5=37 +R6=51 Offset=167 [Bordeaux - Caudéran] @@ -226,7 +235,16 @@ R6=30 Offset=167 -[Boulogne sur mer - Mont Lamvert] +[Bordeaux - Est] +R1=23 +R2=59 +R3=62 +R4=44 +R5=41 +R6=30 +Offset=167 + +[Boulogne sur mer - Mont Lambert] R1=44 R2=28 R3=51 @@ -244,6 +262,15 @@ R6=32 Offset=167 +[Brest - Agglomération] +R1=30 +R2=22 +R3=25 +R4=23 +R5=28 +R6=26 +Offset=167 + [Brest - Monts d'Arrée] R1=30 R2=22 @@ -262,15 +289,6 @@ R6=47 Offset=167 -[Caen - Caen Nord] -R1=31 -R2=30 -R3=32 -R4=33 -R5=50 -R6=58 -Offset=167 - [Caen - Mont Pinçon] R1=26 R2=34 @@ -280,6 +298,15 @@ R6=58 Offset=167 +[Caen - Nord] +R1=31 +R2=30 +R3=32 +R4=33 +R5=50 +R6=58 +Offset=167 + [Cannes - Vallauris] R1=23 R2=26 @@ -307,6 +334,24 @@ R6=47 Offset=167 +[Champagnole - Le Bulay] +R1=58 +R2=50 +R3=63 +R4=37 +R5=32 +R6=28 +Offset=167 + +[Chartres - Agglomération] +R1=41 +R2=38 +R3=23 +R4=31 +R5=37 +R6=40 +Offset=167 + [Chartres - Montlandon] R1=41 R2=38 @@ -334,6 +379,15 @@ R6=32 Offset=167 +[Châtellerault - Agglomération] +R1=37 +R2=59 +R3=62 +R4=54 +R5=27 +R6=24 +Offset=167 + [Clermont-Ferrand - Puy de Dôme] R1=50 R2=31 @@ -343,7 +397,7 @@ R6=32 Offset=167 -[Cluses - Cluses Nord est] +[Cluses - Nord-Est] R1=35 R2=23 R3=39 @@ -379,7 +433,7 @@ R6=35 Offset=167 -[Epinal - Bois de la Vierge] +[Épinal - Bois de la Vierge] R1=56 R2=62 R3=59 @@ -397,6 +451,24 @@ R6=40 Offset=167 +[Foix - Est] +R1=40 +R2=23 +R3=44 +R4=41 +R5=53 +R6=56 +Offset=167 + +[Foix - Sud] +R1=40 +R2=23 +R3=44 +R4=41 +R5=53 +R6=56 +Offset=167 + [Forbach - Kreutzberg] R1=33 R2=56 @@ -406,9 +478,27 @@ R6=36 Offset=167 -[Gex - Gex Nord Est] -R1=45 -R2=55 +[Gap - Agglomération] +R1=57 +R2=25 +R3=51 +R4=22 +R5=54 +R6=28 +Offset=167 + +[Gap - Mont Colombis] +R1=57 +R2=25 +R3=51 +R4=22 +R5=54 +R6=28 +Offset=167 + +[Gex - Nord-Est] +R1=55 +R2=45 R3=39 R4=61 R5=0 @@ -434,8 +524,8 @@ Offset=167 [Hirson - Landouzy] -R1=59 -R2=62 +R1=62 +R2=59 R3=60 R4=57 R5=63 @@ -541,6 +631,15 @@ R6=69 Offset=167 +[Lons-le-Saunier - Agglomération] +R1=58 +R2=50 +R3=63 +R4=37 +R5=32 +R6=28 +Offset=167 + [Lorient - Ploemeur] R1=31 R2=35 @@ -568,6 +667,15 @@ R6=47 Offset=167 +[Mont-Salève - Monnetier-Mornex] +R1=48 +R2=45 +R3=39 +R4=64 +R5=00 +R6=58 +Offset=167 + [Mantes - Maudétour-en-Vexin] R1=48 R2=38 @@ -739,6 +847,15 @@ R6=42 Offset=167 +[Nîmes - Sud-Est] +R1=63 +R2=59 +R3=51 +R4=41 +R5=54 +R6=46 +Offset=167 + [Niort - Canton de Melle] R1=37 R2=59 @@ -757,6 +874,15 @@ R6=51 Offset=167 +[Pamiers - Agglomération] +R1=32 +R2=23 +R3=44 +R4=41 +R5=45 +R6=40 +Offset=167 + [Paris - Tour Eiffel] R1=35 R2=21 @@ -829,6 +955,15 @@ R6=33 Offset=167 +[Quimper - Agglomération] +R1=30 +R2=53 +R3=56 +R4=48 +R5=58 +R6=50 +Offset=167 + [Reims - Hautvillers] R1=32 R2=31 @@ -865,6 +1000,15 @@ R6=32 Offset=167 +[Saint-Gingolph - Mont Pelerin] +R1=63 +R2=45 +R3=39 +R4=61 +R5=41 +R6=58 +Offset=167 + [Saint-Raphaël - Pic de l'Ours] R1=23 R2=26 @@ -892,7 +1036,16 @@ R6=54 Offset=167 -[St Etienne - Croix du Guizay] +[St-Dizier - Agglomération] +R1=23 +R2=47 +R3=41 +R4=44 +R5=26 +R6=28 +Offset=167 + +[St-Étienne - Croix du Guizay] R1=50 R2=23 R3=39 @@ -901,6 +1054,15 @@ R6=26 Offset=167 +[St-Quentin - Sud] +R1=36 +R2=58 +R3=60 +R4=29 +R5=63 +R6=35 +Offset=167 + [Strasbourg - Nordheim] R1=48 R2=47 @@ -974,8 +1136,8 @@ Offset=167 [Valenciennes - Marly] -R1=59 -R2=52 +R1=52 +R2=59 R3=26 R4=36 R5=31 @@ -1000,6 +1162,33 @@ R6=69 Offset=167 +[Vesoul - Agglomération] +R1=51 +R2=43 +R3=54 +R4=40 +R5=38 +R6=46 +Offset=167 + +[Villeneuve-sur-Lot - Nord] +R1=33 +R2=42 +R3=45 +R4=39 +R5=00 +R6=30 +Offset=167 + +[Villers-Cotterêts - Fleury] +R1=36 +R2=31 +R3=60 +R4=34 +R5=45 +R6=42 +Offset=167 + [Vittel - Le Haut de Dimont] R1=56 R2=58 @@ -1019,4 +1208,4 @@ Offset=167 ; -; Mise à jour depuis les données du CSA du 2007-06-13 +; Mise à jour depuis les données du CSA du 2007-10-05 From gingko_pouchintv at nospam.homelinux.org Mon Oct 29 09:18:07 2007 From: gingko_pouchintv at nospam.homelinux.org (Gingko) Date: Mon, 29 Oct 2007 09:18:07 +0100 Subject: [Pouchintv-dev] Mes modifs en cours References: <20071029064534.DC2395F2E9@mail.baysse.fr> Message-ID: <00e101c81a04$3c625dd0$0a00a8c0@gilles> Bonjour, J'envoie ce message pour informer de mes activités de développement en cours sur PouchinTV Mod : Actuellement, je suis en train de développer l'interface de réorganisation des chaînes (activation/désactivation + "chaînes préférées, + réorganisation et renumérotation). J'espère que ceci n'entre en conflit avec personne. Gingko From radius at r4dius.net Mon Oct 29 11:19:38 2007 From: radius at r4dius.net (radius) Date: Mon, 29 Oct 2007 11:19:38 +0100 Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r99 - trunk References: <20071020200432.B2CEF5F2ED@mail.baysse.fr> Message-ID: <200710291119382506932@r4dius.net> Salut, j'ai voulu testé la version r100 à partir d'une config vide, avec l'offset a 0 (j'ai une carte hauppauge) ca ne trouve aucune chaine, j'ai du forcer l'offset a 1 pour que ca marche ^^. A+ Author: gingko Date: 2007-10-20 22:04:32 +0200 (Sat, 20 Oct 2007) New Revision: 99 Modified: trunk/settings.cpp Log: Correctif (le r?\195?\169pertoire des captures d'?\195?\169cran n'?\195?\169tait plus modifiable). Modified: trunk/settings.cpp =================================================================== --- trunk/settings.cpp 2007-10-20 13:36:58 UTC (rev 98) +++ trunk/settings.cpp 2007-10-20 20:04:32 UTC (rev 99) @@ -548,7 +548,7 @@ case PSN_APPLY: // Application des changements SendMessage(hVideoDirItem, WM_GETTEXT, _countof(video_dir), (LPARAM)video_dir); - SendMessage(hSshotDirItem, WM_SETTEXT, + SendMessage(hSshotDirItem, WM_GETTEXT, _countof(screenshots_dir), (LPARAM)screenshots_dir); return psn_result(hDlg, PSNRET_NOERROR); } _______________________________________________ Pouchintv-dev mailing list Pouchintv-dev at baysse.fr https://listes.baysse.fr/listinfo/pouchintv-dev . -------------- section suivante -------------- Une pièce jointe HTML a été nettoyée... URL: http://listes.baysse.fr/pipermail/pouchintv-dev/attachments/20071029/aa710e70/attachment.html