void SubscribeService(mUpnpControlPoint *ctrlPoint) { mUpnpDevice *selDev; mUpnpService *selService; bool subSuccess; printf("Subscribe Device\n"); mupnp_controlpoint_lock(ctrlPoint); selDev = SelectDevice(ctrlPoint); if (selDev == NULL) { mupnp_controlpoint_unlock(ctrlPoint); return; } selService = SelectService(selDev); if (selService == NULL) { mupnp_controlpoint_unlock(ctrlPoint); return; } subSuccess = mupnp_controlpoint_subscribe(ctrlPoint, selService, 300); printf("Subscribe Result(%d) = %s\n", (int)subSuccess, (subSuccess == true) ? mupnp_service_getsubscriptionsid(selService) : ""); mupnp_controlpoint_unlock(ctrlPoint); }
void QueryDevice(mUpnpControlPoint *ctrlPoint) { mUpnpDevice *selDev; mUpnpService *selService; mUpnpStateVariable *selStateVar; bool querySuccess; char *stateValue; printf("Query Device\n"); selDev = SelectDevice(ctrlPoint); if (selDev == NULL) return; selService = SelectService(selDev); if (selService == NULL) return; selStateVar = SelectStateVariable(selService); if (selStateVar == NULL) return; querySuccess = mupnp_statevariable_post(selStateVar); stateValue = mupnp_statevariable_getvalue(selStateVar); printf("Query Result(%d) = %s\n", (int)querySuccess, (stateValue != NULL) ? stateValue : ""); }
void CEpgDataCap_BonDlg::OnCbnSelchangeComboService() { // TODO: ここにコントロール通知ハンドラー コードを追加します。 int sel = this->combService.GetCurSel(); if( sel != CB_ERR ){ DWORD index = (DWORD)this->combService.GetItemData(sel); SelectService(this->serviceList[index].originalNetworkID, this->serviceList[index].transportStreamID, this->serviceList[index].serviceID, this->serviceList[index].space, this->serviceList[index].ch ); } ChgIconStatus(); }
void CEpgDataCap_BonDlg::OnCbnSelchangeComboTuner() { // TODO: ここにコントロール通知ハンドラー コードを追加します。 KillTimer(TIMER_STATUS_UPDATE); WCHAR buff[512]; if( GetWindowText(GetDlgItem(IDC_COMBO_TUNER), buff, 512) > 0 ){ SelectBonDriver(buff); int sel = ComboBox_GetCurSel(GetDlgItem(IDC_COMBO_SERVICE)); if( sel != CB_ERR ){ DWORD index = (DWORD)ComboBox_GetItemData(GetDlgItem(IDC_COMBO_SERVICE), sel); SelectService(this->serviceList[index].originalNetworkID, this->serviceList[index].transportStreamID, this->serviceList[index].serviceID, this->serviceList[index].space, this->serviceList[index].ch ); } } ChgIconStatus(); SetTimer(TIMER_STATUS_UPDATE, 1000, NULL); }
void CEpgDataCap_BonDlg::OnCbnSelchangeComboTuner() { // TODO: ここにコントロール通知ハンドラー コードを追加します。 KillTimer(TIMER_STATUS_UPDATE); CString buff=L""; this->combTuner.GetWindowText(buff); if( buff.IsEmpty() == false ){ SelectBonDriver(buff.GetBuffer(0)); int sel = this->combService.GetCurSel(); if( sel != CB_ERR ){ DWORD index = (DWORD)this->combService.GetItemData(sel); SelectService(this->serviceList[index].originalNetworkID, this->serviceList[index].transportStreamID, this->serviceList[index].serviceID, this->serviceList[index].space, this->serviceList[index].ch ); } } ChgIconStatus(); SetTimer(TIMER_STATUS_UPDATE, 1000, NULL); }
void UnsubscribeService(mUpnpControlPoint *ctrlPoint) { mUpnpDevice *selDev; mUpnpService *selService; bool subSuccess; printf("Query Device\n"); selDev = SelectDevice(ctrlPoint); if (selDev == NULL) return; selService = SelectService(selDev); if (selService == NULL) return; subSuccess = mupnp_controlpoint_unsubscribe(ctrlPoint, selService); printf("Unsubscribe Result(%d)\n", (int)subSuccess); }
void CEpgDataCap_BonDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: ここにメッセージ ハンドラー コードを追加するか、既定の処理を呼び出します。 switch(nIDEvent){ case TIMER_INIT_DLG: { KillTimer( TIMER_INIT_DLG ); if( this->iniMin == TRUE && this->minTask == TRUE){ ShowWindow(SW_HIDE); } } break; case TIMER_STATUS_UPDATE: { KillTimer( TIMER_STATUS_UPDATE ); SetThreadExecutionState(ES_SYSTEM_REQUIRED); int iLine = this->editStatus.GetFirstVisibleLine(); float signal = 0; DWORD space = 0; DWORD ch = 0; ULONGLONG drop = 0; ULONGLONG scramble = 0; vector<NW_SEND_INFO> udpSendList; vector<NW_SEND_INFO> tcpSendList; BOOL ret = this->main.GetViewStatusInfo(&signal, &space, &ch, &drop, &scramble, &udpSendList, &tcpSendList); if(ret==TRUE){ this->statusLog.Format(L"Signal: %.02f Drop: %I64d Scramble: %I64d space: %d ch: %d",signal, drop, scramble, space, ch); }else{ this->statusLog.Format(L"Signal: %.02f Drop: %I64d Scramble: %I64d",signal, drop, scramble); } this->statusLog += L"\r\n"; CString udp = L""; if( udpSendList.size() > 0 ){ udp = "UDP送信:"; for( size_t i=0; i<udpSendList.size(); i++ ){ CString buff; if( udpSendList[i].broadcastFlag == FALSE ){ buff.Format(L"%s:%d ",udpSendList[i].ipString.c_str(), udpSendList[i].port); }else{ buff.Format(L"%s:%d(Broadcast) ",udpSendList[i].ipString.c_str(), udpSendList[i].port); } udp += buff; } udp += L"\r\n"; } this->statusLog += udp; CString tcp = L""; if( tcpSendList.size() > 0 ){ tcp = "TCP送信:"; for( size_t i=0; i<tcpSendList.size(); i++ ){ CString buff; buff.Format(L"%s:%d ",tcpSendList[i].ipString.c_str(), tcpSendList[i].port); tcp += buff; } tcp += L"\r\n"; } this->statusLog += tcp; SetDlgItemText(IDC_EDIT_STATUS, this->statusLog); editStatus.LineScroll(iLine); CString info = L""; this->main.GetEpgInfo(this->btnPgNext.GetCheck(), &info); if( this->pgInfo.Compare(info) != 0 ){ this->pgInfo = info; SetDlgItemText(IDC_EDIT_PG_INFO, this->pgInfo); } SetTimer(TIMER_STATUS_UPDATE, 1000, NULL); } break; case TIMER_CHSCAN_STATSU: { KillTimer( TIMER_CHSCAN_STATSU ); DWORD space = 0; DWORD ch = 0; wstring chName = L""; DWORD chkNum = 0; DWORD totalNum = 0; DWORD status = this->main.GetChScanStatus(&space, &ch, &chName, &chkNum, &totalNum); if( status == ST_WORKING ){ this->log.Format(L"%s (%d/%d 残り約 %d 秒)\r\n", chName.c_str(), chkNum, totalNum, (totalNum - chkNum)*10); SetDlgItemText(IDC_EDIT_LOG, this->log); SetTimer(TIMER_CHSCAN_STATSU, 1000, NULL); }else if( status == ST_CANCEL ){ KillTimer(TIMER_CHSCAN_STATSU); this->log = L"キャンセルされました\r\n"; SetDlgItemText(IDC_EDIT_LOG, this->log); }else if( status == ST_COMPLETE ){ KillTimer(TIMER_CHSCAN_STATSU); this->log = L"終了しました\r\n"; SetDlgItemText(IDC_EDIT_LOG, this->log); ReloadServiceList(); int sel = this->combService.GetCurSel(); if( sel != CB_ERR ){ DWORD index = (DWORD)this->combService.GetItemData(sel); SelectService(this->serviceList[index].originalNetworkID, this->serviceList[index].transportStreamID, this->serviceList[index].serviceID, this->serviceList[index].space, this->serviceList[index].ch ); } BtnUpdate(GUI_NORMAL); ChgIconStatus(); //同じサービスが別の物理チャンネルにあるかチェック wstring msg = L""; for( size_t i=0; i<this->serviceList.size(); i++ ){ for( size_t j=i+1; j<this->serviceList.size(); j++ ){ if( this->serviceList[i].originalNetworkID == this->serviceList[j].originalNetworkID && this->serviceList[i].transportStreamID == this->serviceList[j].transportStreamID && this->serviceList[i].serviceID == this->serviceList[j].serviceID ){ wstring log = L""; Format(log, L"%s space:%d ch:%d <=> %s space:%d ch:%d\r\n", this->serviceList[i].serviceName.c_str(), this->serviceList[i].space, this->serviceList[i].ch, this->serviceList[j].serviceName.c_str(), this->serviceList[j].space, this->serviceList[j].ch); msg += log; break; } } } if( msg.size() > 0){ wstring log = L"同一サービスが複数の物理チャンネルで検出されました。\r\n受信環境のよい物理チャンネルのサービスのみ残すように設定を行ってください。\r\n正常に録画できない可能性が出てきます。\r\n\r\n"; log += msg; MessageBox(log.c_str()); } } } break; case TIMER_EPGCAP_STATSU: { KillTimer( TIMER_EPGCAP_STATSU ); EPGCAP_SERVICE_INFO info; DWORD status = this->main.GetEpgCapStatus(&info); if( status == ST_WORKING ){ int sel = this->combService.GetCurSel(); if( sel != CB_ERR ){ DWORD index = (DWORD)this->combService.GetItemData(sel); if( info.ONID != this->serviceList[index].originalNetworkID || info.TSID != this->serviceList[index].transportStreamID || info.SID != this->serviceList[index].serviceID ){ } this->initONID = info.ONID; this->initTSID = info.TSID; this->initSID = info.SID; ReloadServiceList(); this->main.SetSID(info.SID); } this->log = L"EPG取得中\r\n"; SetDlgItemText(IDC_EDIT_LOG, this->log); SetTimer(TIMER_EPGCAP_STATSU, 1000, NULL); }else if( status == ST_CANCEL ){ KillTimer(TIMER_EPGCAP_STATSU); this->log = L"キャンセルされました\r\n"; SetDlgItemText(IDC_EDIT_LOG, this->log); }else if( status == ST_COMPLETE ){ KillTimer(TIMER_EPGCAP_STATSU); this->log = L"終了しました\r\n"; SetDlgItemText(IDC_EDIT_LOG, this->log); BtnUpdate(GUI_NORMAL); ChgIconStatus(); } } break; case TIMER_REC_END: { this->main.StopRec(); KillTimer(TIMER_REC_END); this->log = L"録画停止しました\r\n"; SetDlgItemText(IDC_EDIT_LOG, this->log); BtnUpdate(GUI_NORMAL); chkRecSet.SetCheck(FALSE); ChgIconStatus(); } break; case RETRY_ADD_TRAY: { KillTimer(RETRY_ADD_TRAY); CString buff=L""; wstring bonFile = L""; this->main.GetOpenBonDriver(&bonFile); CString strBuff2=L""; this->combService.GetWindowText(strBuff2); buff.Format(L"%s : %s", bonFile.c_str(), strBuff2.GetBuffer(0)); HICON setIcon = this->iconBlue; if( this->main.IsRec() == TRUE ){ setIcon = this->iconRed; }else if( this->main.GetEpgCapStatus(NULL) == ST_WORKING ){ setIcon = this->iconGreen; }else if( this->main.GetOpenBonDriver(NULL) == FALSE ){ setIcon = this->iconGray; } if( AddTaskBar( GetSafeHwnd(), WM_TRAY_PUSHICON, TRAYICON_ID, setIcon, buff ) == FALSE ){ SetTimer(RETRY_ADD_TRAY, 5000, NULL); } } break; default: break; } CDialogEx::OnTimer(nIDEvent); }
BOOL CEpgDataCap_BonDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // このダイアログのアイコンを設定します。アプリケーションのメイン ウィンドウがダイアログでない場合、 // Framework は、この設定を自動的に行います。 SetIcon(m_hIcon2, TRUE); // 大きいアイコンの設定 SetIcon(m_hIcon, FALSE); // 小さいアイコンの設定 // TODO: 初期化をここに追加します。 this->main.ReloadSetting(); for( int i=0; i<25; i++ ){ CString buff; buff.Format(L"%d",i); int index = combRecH.AddString(buff); combRecH.SetItemData(index, i); } combRecH.SetCurSel(0); for( int i=0; i<59; i++ ){ CString buff; buff.Format(L"%d",i); int index = combRecM.AddString(buff); combRecM.SetItemData(index, i); } combRecM.SetCurSel(0); //BonDriverの一覧取得 ReloadBonDriver(); //BonDriverのオープン DWORD err = NO_ERR; if( this->iniBonDriver.IsEmpty() == false ){ err = SelectBonDriver(this->iniBonDriver.GetBuffer(0), TRUE); Sleep(this->initOpenWait); }else{ map<int, wstring>::iterator itr; itr = this->bonList.begin(); if( itr != this->bonList.end() ){ err = SelectBonDriver(itr->second.c_str()); }else{ err = ERR_FALSE; this->log += L"BonDriverが見つかりませんでした\r\n"; } } if( err == NO_ERR ){ //チャンネル変更 if( this->initONID != -1 && this->initTSID != -1 && this->initSID != -1 ){ SelectService(this->initONID, this->initTSID, this->initSID); this->initONID = -1; this->initTSID = -1; this->initSID = -1; Sleep(this->initChgWait); }else{ int sel = this->combService.GetCurSel(); if( sel != CB_ERR ){ DWORD index = (DWORD)this->combService.GetItemData(sel); SelectService(this->serviceList[index].originalNetworkID, this->serviceList[index].transportStreamID, this->serviceList[index].serviceID, this->serviceList[index].space, this->serviceList[index].ch ); } } } //ウインドウの復元 WINDOWPLACEMENT Pos; Pos.length = sizeof(WINDOWPLACEMENT); Pos.flags = NULL; if( this->iniMin == FALSE ){ Pos.showCmd = SW_SHOW; }else{ Pos.showCmd = SW_SHOWMINNOACTIVE; } Pos.rcNormalPosition.left = GetPrivateProfileInt(L"SET_WINDOW", L"left", 0, this->moduleIniPath); Pos.rcNormalPosition.right = GetPrivateProfileInt(L"SET_WINDOW", L"right", 0, this->moduleIniPath); Pos.rcNormalPosition.top = GetPrivateProfileInt(L"SET_WINDOW", L"top", 0, this->moduleIniPath); Pos.rcNormalPosition.bottom = GetPrivateProfileInt(L"SET_WINDOW", L"bottom", 0, this->moduleIniPath); if( Pos.rcNormalPosition.left != 0 && Pos.rcNormalPosition.right != 0 && Pos.rcNormalPosition.top != 0 && Pos.rcNormalPosition.bottom != 0 ){ SetWindowPlacement(&Pos); } SetTimer(TIMER_STATUS_UPDATE, 1000, NULL); SetTimer(TIMER_INIT_DLG, 1, NULL); this->main.SetHwnd(GetSafeHwnd()); if( this->iniNetwork == TRUE ){ if( this->iniUDP == TRUE || this->iniTCP == TRUE ){ if( this->iniUDP == TRUE ){ this->chkUDP.SetCheck(TRUE); } if( this->iniTCP == TRUE ){ this->chkTCP.SetCheck(TRUE); } }else{ this->chkUDP.SetCheck(GetPrivateProfileInt(L"SET", L"ChkUDP", 0, this->moduleIniPath)); this->chkTCP.SetCheck(GetPrivateProfileInt(L"SET", L"ChkTCP", 0, this->moduleIniPath)); } } ReloadNWSet(); UpdateData(FALSE); this->main.StartServer(); return TRUE; // フォーカスをコントロールに設定した場合を除き、TRUE を返します。 }
BOOL CEpgDataCap_BonDlg::OnInitDialog() { // このダイアログのアイコンを設定します。アプリケーションのメイン ウィンドウがダイアログでない場合、 // Framework は、この設定を自動的に行います。 SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)m_hIcon2); // 大きいアイコンの設定 SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)m_hIcon); // 小さいアイコンの設定 // TODO: 初期化をここに追加します。 this->main.ReloadSetting(); for( int i=0; i<24; i++ ){ WCHAR buff[32]; wsprintf(buff, L"%d",i); int index = ComboBox_AddString(GetDlgItem(IDC_COMBO_REC_H), buff); ComboBox_SetItemData(GetDlgItem(IDC_COMBO_REC_H), index, i); } ComboBox_SetCurSel(GetDlgItem(IDC_COMBO_REC_H), 0); for( int i=0; i<60; i++ ){ WCHAR buff[32]; wsprintf(buff, L"%d",i); int index = ComboBox_AddString(GetDlgItem(IDC_COMBO_REC_M), buff); ComboBox_SetItemData(GetDlgItem(IDC_COMBO_REC_M), index, i); } ComboBox_SetCurSel(GetDlgItem(IDC_COMBO_REC_M), 0); //BonDriverの一覧取得 ReloadBonDriver(); //BonDriverのオープン DWORD err = NO_ERR; if( this->iniBonDriver.empty() == false ){ err = SelectBonDriver(this->iniBonDriver.c_str(), TRUE); Sleep(this->initOpenWait); }else{ if( this->bonList.empty() == false ){ err = SelectBonDriver(this->bonList.front().c_str()); }else{ err = ERR_FALSE; WCHAR log[512 + 64] = L""; GetDlgItemText(m_hWnd, IDC_EDIT_LOG, log, 512); lstrcat(log, L"BonDriverが見つかりませんでした\r\n"); SetDlgItemText(m_hWnd, IDC_EDIT_LOG, log); } } if( err == NO_ERR ){ //チャンネル変更 if( this->initONID != -1 && this->initTSID != -1 && this->initSID != -1 ){ SelectService(this->initONID, this->initTSID, this->initSID); this->initONID = -1; this->initTSID = -1; this->initSID = -1; Sleep(this->initChgWait); }else{ int sel = ComboBox_GetCurSel(GetDlgItem(IDC_COMBO_SERVICE)); if( sel != CB_ERR ){ DWORD index = (DWORD)ComboBox_GetItemData(GetDlgItem(IDC_COMBO_SERVICE), sel); SelectService(this->serviceList[index].originalNetworkID, this->serviceList[index].transportStreamID, this->serviceList[index].serviceID, this->serviceList[index].space, this->serviceList[index].ch ); } } } //ウインドウの復元 WINDOWPLACEMENT Pos; Pos.length = sizeof(WINDOWPLACEMENT); Pos.flags = NULL; if( this->iniMin == FALSE ){ Pos.showCmd = SW_SHOW; }else{ Pos.showCmd = SW_SHOWMINNOACTIVE; } Pos.rcNormalPosition.left = GetPrivateProfileInt(L"SET_WINDOW", L"left", 0, this->moduleIniPath.c_str()); Pos.rcNormalPosition.right = GetPrivateProfileInt(L"SET_WINDOW", L"right", 0, this->moduleIniPath.c_str()); Pos.rcNormalPosition.top = GetPrivateProfileInt(L"SET_WINDOW", L"top", 0, this->moduleIniPath.c_str()); Pos.rcNormalPosition.bottom = GetPrivateProfileInt(L"SET_WINDOW", L"bottom", 0, this->moduleIniPath.c_str()); if( Pos.rcNormalPosition.left != 0 && Pos.rcNormalPosition.right != 0 && Pos.rcNormalPosition.top != 0 && Pos.rcNormalPosition.bottom != 0 ){ SetWindowPlacement(m_hWnd, &Pos); } SetTimer(TIMER_STATUS_UPDATE, 1000, NULL); SetTimer(TIMER_INIT_DLG, 1, NULL); this->main.SetHwnd(GetSafeHwnd()); if( this->iniNetwork == TRUE ){ if( this->iniUDP == TRUE || this->iniTCP == TRUE ){ if( this->iniUDP == TRUE ){ Button_SetCheck(GetDlgItem(IDC_CHECK_UDP), BST_CHECKED); } if( this->iniTCP == TRUE ){ Button_SetCheck(GetDlgItem(IDC_CHECK_TCP), BST_CHECKED); } }else{ Button_SetCheck(GetDlgItem(IDC_CHECK_UDP), GetPrivateProfileInt(L"SET", L"ChkUDP", 0, this->moduleIniPath.c_str())); Button_SetCheck(GetDlgItem(IDC_CHECK_TCP), GetPrivateProfileInt(L"SET", L"ChkTCP", 0, this->moduleIniPath.c_str())); } } ReloadNWSet(); this->main.StartServer(); return TRUE; // フォーカスをコントロールに設定した場合を除き、TRUE を返します。 }
void ControlDeviceAlter(mUpnpControlPoint *ctrlPoint, int alteration_mask) { mUpnpDevice *selDev; mUpnpService *selService; mUpnpAction *selAction; bool actionSuccess; mUpnpArgument *arg; char argValue[2048]; printf("Control Device\n"); selDev = SelectDevice(ctrlPoint); if (selDev == NULL) return; selService = SelectService(selDev); if (selService == NULL) return; selAction = SelectAction(selService); if (selAction == NULL) return; for (arg = mupnp_action_getarguments(selAction); arg; arg = mupnp_argument_next(arg)) { if (mupnp_argument_isindirection(arg) == true) { printf("%s : ", mupnp_argument_getname(arg)); if (scanf("%s", argValue) == 1) mupnp_argument_setvalue(arg, argValue); } } /* NOTE: Go through selAction memory management... */ if (alteration_mask & CMD_LOOP_ACTION_CALLS) { int loop_count, i; printf("\nHow many times action should be sent?"); if ( 1 == scanf("%d", &loop_count) ) { printf("\n"); for (i=0; i<loop_count; i++) { actionSuccess = mupnp_action_post(selAction); printf("Control Result(%d)\n", (int)actionSuccess); } mupnp_sleep(3000); for ( arg = mupnp_action_getarguments(selAction); arg; arg = mupnp_argument_next(arg)) { if (mupnp_argument_isoutdirection(arg) == true) printf(" %s = %s\n", mupnp_argument_getname(arg), mupnp_argument_getvalue(arg)); } mupnp_sleep(2000); } } if ((alteration_mask & CMD_NO_ALTERATIONS) == CMD_NO_ALTERATIONS) { actionSuccess = mupnp_action_post(selAction); printf("Control Result(%d)\n", (int)actionSuccess); for (arg = mupnp_action_getarguments(selAction); arg; arg = mupnp_argument_next(arg)) { if (mupnp_argument_isoutdirection(arg) == true) printf(" %s = %s\n", mupnp_argument_getname(arg), mupnp_argument_getvalue(arg)); } } }