#include "stdafx.h" #include "rilstate.h" #include "debug.h" RILState::RILState() { m_bRilEnabled= true; m_dlg= NULL; } RILState::~RILState() { m_dlg= NULL; } void RILState::SetView(CTstmodemDlg& dlg) { m_dlg= &dlg; } bool RILState::open() { m_hRil= CreateFile(L"RIL1:",GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_EXISTING,FILE_ATTRIBUTE_SYSTEM,0); if (m_hRil==NULL || m_hRil==INVALID_HANDLE_VALUE) { error("CreateFile('RIL1:')"); m_hRil= NULL; return false; } return true; } bool RILState::disable() { if (m_hRil==NULL) return false; DWORD nReturned; DWORD rildevresult; if (!DeviceIoControl(m_hRil, 0x03000314L,0,0, &rildevresult, sizeof(DWORD), &nReturned,0)) { error("DeviceIoControl ril 0x03000314L"); return false; } m_bRilEnabled= false; return true; } bool RILState::enable() { if (m_hRil==NULL) return false; DWORD nReturned; DWORD rildevresult; if (!DeviceIoControl(m_hRil, 0x03000318L,0,0, &rildevresult, sizeof(DWORD), &nReturned,0)) { error("DeviceIoControl ril 0x03000318L"); return false; } m_bRilEnabled= true; return true; } bool RILState::close() { if (m_hRil==NULL) return false; CloseHandle(m_hRil); m_hRil= NULL; return true; }