Update of /cvsroot/bdadev/TuneReqStore In directory sc8-pr-cvs1:/tmp/cvs-serv30984 Modified Files: ProgramInfo.cpp ProgramInfo.h StdAfx.cpp StdAfx.h TuneInfo.cpp TuneInfo.h TuneReqStore.cpp TuneReqStore.idl TuneRequestStore.cpp TuneRequestStore.h Log Message: Added schedule functionality (untested) and some code clean up Index: ProgramInfo.cpp =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/ProgramInfo.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ProgramInfo.cpp 20 Feb 2003 17:40:32 -0000 1.1 --- ProgramInfo.cpp 21 Feb 2003 16:36:43 -0000 1.2 *************** *** 1,3 **** ! // ProgramInfo.cpp : Implementation of CProgramInfo #include "stdafx.h" #include "TuneReqStore.h" --- 1,22 ---- ! ///////////////////////////////////////////////////////////////////////////// ! // $Id$ ! ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that uses XML to persist tune requests ! // Copyright (c) 2003 John Adcock. All rights reserved. ! ///////////////////////////////////////////////////////////////////////////// ! // ! // This file is subject to the terms of the GNU General Public License as ! // published by the Free Software Foundation. A copy of this license is ! // included with this software distribution in the file COPYING.txt. If you ! // do not have a copy, you may obtain a copy by writing to the Free ! // Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ! // ! // This software 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 ! // ! ///////////////////////////////////////////////////////////////////////////// ! #include "stdafx.h" #include "TuneReqStore.h" *************** *** 51,52 **** --- 70,104 ---- return S_OK; } + + STDMETHODIMP CProgramInfo::get_StartTime(DATE *pVal) + { + *pVal = m_StartDate; + return S_OK; + } + + STDMETHODIMP CProgramInfo::put_StartTime(DATE newVal) + { + m_StartDate = newVal; + return S_OK; + } + + STDMETHODIMP CProgramInfo::get_EndTime(DATE *pVal) + { + *pVal = m_EndDate; + return S_OK; + } + + STDMETHODIMP CProgramInfo::put_EndTime(DATE newVal) + { + m_EndDate = newVal; + return S_OK; + } + + ///////////////////////////////////////////////////////////////////////////// + // CVS Log + // + // $Log$ + // Revision 1.2 2003/02/21 16:36:43 adcockj + // Added schedule functionality (untested) and some code clean up + // + ///////////////////////////////////////////////////////////////////////////// Index: ProgramInfo.h =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/ProgramInfo.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ProgramInfo.h 20 Feb 2003 17:40:34 -0000 1.1 --- ProgramInfo.h 21 Feb 2003 16:36:43 -0000 1.2 *************** *** 1,3 **** ! // ProgramInfo.h : Declaration of the CProgramInfo #ifndef __PROGRAMINFO_H_ --- 1,21 ---- ! ///////////////////////////////////////////////////////////////////////////// ! // $Id$ ! ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that uses XML to persist tune requests ! // Copyright (c) 2003 John Adcock. All rights reserved. ! ///////////////////////////////////////////////////////////////////////////// ! // ! // This file is subject to the terms of the GNU General Public License as ! // published by the Free Software Foundation. A copy of this license is ! // included with this software distribution in the file COPYING.txt. If you ! // do not have a copy, you may obtain a copy by writing to the Free ! // Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ! // ! // This software 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 ! // ! ///////////////////////////////////////////////////////////////////////////// #ifndef __PROGRAMINFO_H_ *************** *** 36,39 **** --- 54,61 ---- // IProgramInfo public: + STDMETHOD(get_EndTime)(/*[out, retval]*/ DATE *pVal); + STDMETHOD(put_EndTime)(/*[in]*/ DATE newVal); + STDMETHOD(get_StartTime)(/*[out, retval]*/ DATE *pVal); + STDMETHOD(put_StartTime)(/*[in]*/ DATE newVal); STDMETHOD(get_Id)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(put_Id)(/*[in]*/ BSTR newVal); *************** *** 49,52 **** --- 71,76 ---- CComBSTR m_Description; CComBSTR m_Name; + DATE m_EndDate; + DATE m_StartDate; }; Index: StdAfx.cpp =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/StdAfx.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StdAfx.cpp 19 Feb 2003 17:21:42 -0000 1.2 --- StdAfx.cpp 21 Feb 2003 16:36:43 -0000 1.3 *************** *** 2,6 **** // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that used XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// --- 2,6 ---- // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that uses XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// *************** *** 32,35 **** --- 32,38 ---- // // $Log$ + // Revision 1.3 2003/02/21 16:36:43 adcockj + // Added schedule functionality (untested) and some code clean up + // // Revision 1.2 2003/02/19 17:21:42 adcockj // removed midl generated file Index: StdAfx.h =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/StdAfx.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StdAfx.h 20 Feb 2003 07:53:39 -0000 1.3 --- StdAfx.h 21 Feb 2003 16:36:43 -0000 1.4 *************** *** 35,38 **** --- 35,39 ---- #include <stack> #include <vector> + #include <ctime> #define CHECK(x) { HRESULT __hr(x); if(FAILED(__hr)) {ATLTRACE(#x " Returned %8x\n", __hr); _asm{int 3}; return __hr;}} Index: TuneInfo.cpp =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/TuneInfo.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TuneInfo.cpp 20 Feb 2003 17:39:37 -0000 1.4 --- TuneInfo.cpp 21 Feb 2003 16:36:43 -0000 1.5 *************** *** 2,6 **** // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that used XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// --- 2,6 ---- // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that uses XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// *************** *** 142,145 **** --- 142,148 ---- // // $Log$ + // Revision 1.5 2003/02/21 16:36:43 adcockj + // Added schedule functionality (untested) and some code clean up + // // Revision 1.4 2003/02/20 17:39:37 adcockj // Interim Check in of Schedule storage *************** *** 152,154 **** // ///////////////////////////////////////////////////////////////////////////// - --- 155,156 ---- Index: TuneInfo.h =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/TuneInfo.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TuneInfo.h 20 Feb 2003 17:39:38 -0000 1.5 --- TuneInfo.h 21 Feb 2003 16:36:43 -0000 1.6 *************** *** 2,6 **** // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that used XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// --- 2,6 ---- // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that uses XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// *************** *** 67,70 **** --- 67,72 ---- unsigned m_bRequiresSave:1; + std::vector<IProgramInfo*> m_ProgramInfos; + private: void EmptyArray(); *************** *** 73,77 **** typedef CComEnumOnSTL<IEnumProgramInfo, &IID_IEnumProgramInfo, IProgramInfo*, _Copy<IProgramInfo*>, std::vector<IProgramInfo*> > ComSTLEnum; - std::vector<IProgramInfo*> m_ProgramInfos; ITuneRequest* m_TuneRequest; --- 75,78 ---- Index: TuneReqStore.cpp =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/TuneReqStore.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TuneReqStore.cpp 20 Feb 2003 17:39:38 -0000 1.4 --- TuneReqStore.cpp 21 Feb 2003 16:36:43 -0000 1.5 *************** *** 2,6 **** // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that used XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// --- 2,6 ---- // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that uses XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// *************** *** 95,98 **** --- 95,101 ---- // // $Log$ + // Revision 1.5 2003/02/21 16:36:43 adcockj + // Added schedule functionality (untested) and some code clean up + // // Revision 1.4 2003/02/20 17:39:38 adcockj // Interim Check in of Schedule storage Index: TuneReqStore.idl =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/TuneReqStore.idl,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TuneReqStore.idl 21 Feb 2003 11:46:34 -0000 1.5 --- TuneReqStore.idl 21 Feb 2003 16:36:43 -0000 1.6 *************** *** 2,6 **** // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that used XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// --- 2,6 ---- // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that uses XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// *************** *** 40,43 **** --- 40,47 ---- [propget, id(3), helpstring("property Id")] HRESULT Id([out, retval] BSTR *pVal); [propput, id(3), helpstring("property Id")] HRESULT Id([in] BSTR newVal); + [propget, id(4), helpstring("property StartTime")] HRESULT StartTime([out, retval] DATE *pVal); + [propput, id(4), helpstring("property StartTime")] HRESULT StartTime([in] DATE newVal); + [propget, id(5), helpstring("property EndTime")] HRESULT EndTime([out, retval] DATE *pVal); + [propput, id(5), helpstring("property EndTime")] HRESULT EndTime([in] DATE newVal); }; *************** *** 132,136 **** [ uuid(603A3F82-4325-11D7-B840-0002A5623377), ! helpstring("TuneInfo Class") ] coclass TuneInfo --- 136,141 ---- [ uuid(603A3F82-4325-11D7-B840-0002A5623377), ! helpstring("TuneInfo Class"), ! noncreatable ] coclass TuneInfo *************** *** 140,144 **** [ uuid(5DACDF4E-4422-11D7-B840-0002A5623377), ! helpstring("ProgramInfo Class") ] coclass ProgramInfo --- 145,150 ---- [ uuid(5DACDF4E-4422-11D7-B840-0002A5623377), ! helpstring("ProgramInfo Class"), ! noncreatable ] coclass ProgramInfo *************** *** 152,155 **** --- 158,164 ---- // // $Log$ + // Revision 1.6 2003/02/21 16:36:43 adcockj + // Added schedule functionality (untested) and some code clean up + // // Revision 1.5 2003/02/21 11:46:34 adcockj // Changed Attach and Detach function names Index: TuneRequestStore.cpp =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/TuneRequestStore.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TuneRequestStore.cpp 21 Feb 2003 12:09:10 -0000 1.9 --- TuneRequestStore.cpp 21 Feb 2003 16:36:43 -0000 1.10 *************** *** 2,6 **** // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that used XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// --- 2,6 ---- // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that uses XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// *************** *** 40,43 **** --- 40,44 ---- #include "TuneRequestStore.h" #include "TuneInfo.h" + #include "ProgramInfo.h" ///////////////////////////////////////////////////////////////////////////// *************** *** 78,82 **** { // make sure we've got the latest info ! UpdateProgramInfo(); if (ppUnk == NULL) --- 79,83 ---- { // make sure we've got the latest info ! UpdateInfo(); if (ppUnk == NULL) *************** *** 108,112 **** { // make sure we've got the latest info ! UpdateProgramInfo(); if (pVal == NULL) --- 109,113 ---- { // make sure we've got the latest info ! UpdateInfo(); if (pVal == NULL) *************** *** 130,134 **** { // make sure we've got the latest info ! UpdateProgramInfo(); *pVal = m_TuneInfos.size(); --- 131,135 ---- { // make sure we've got the latest info ! UpdateInfo(); *pVal = m_TuneInfos.size(); *************** *** 196,200 **** { // make sure we've got the latest info ! UpdateProgramInfo(); // *** Warning *** This function is NOT reentrant --- 197,201 ---- { // make sure we've got the latest info ! UpdateInfo(); // *** Warning *** This function is NOT reentrant *************** *** 282,286 **** } ATLTRACE("Failed to find TIF\n"); ! return Result; } --- 283,287 ---- } ATLTRACE("Failed to find TIF\n"); ! return E_FAIL; } *************** *** 289,293 **** // make sure we've got the latest info // since this is the last chance we have to talk to the TIF ! UpdateProgramInfo(); // unadvise GuideDataEvent object --- 290,294 ---- // make sure we've got the latest info // since this is the last chance we have to talk to the TIF ! UpdateInfo(); // unadvise GuideDataEvent object *************** *** 305,309 **** /////////////////////////////////////////////////////////////////////////////// ! // XML storage functions /////////////////////////////////////////////////////////////////////////////// STDMETHODIMP CTuneRequestStore::Read(LPCOLESTR pwszPropNameIn, VARIANT *pVar, IErrorLog *pErrorLog) --- 306,310 ---- /////////////////////////////////////////////////////////////////////////////// ! // IPropertyBag interface /////////////////////////////////////////////////////////////////////////////// STDMETHODIMP CTuneRequestStore::Read(LPCOLESTR pwszPropNameIn, VARIANT *pVar, IErrorLog *pErrorLog) *************** *** 549,552 **** --- 550,556 ---- } + /////////////////////////////////////////////////////////////////////////////// + // XML storage functions + /////////////////////////////////////////////////////////////////////////////// bool CTuneRequestStore::IsValidXMLTagChar(WCHAR c) *************** *** 762,785 **** // Tuning Information maintenance routines /////////////////////////////////////////////////////////////////////////////// ! ! HRESULT CTuneRequestStore::UpdateTuneRequest(BSTR Id, ITuneRequest* TuneRequest, BSTR Name) { HRESULT Result = S_OK; for(int i(0); i < m_TuneInfos.size(); ++i) { if(m_TuneInfos[i] != NULL) { ! CComBSTR Id2; ! Result = m_TuneInfos[i]->get_UniqueID(&Id2); ! CHECK(Result); ! if(Id2 == Id) { ! Result = m_TuneInfos[i]->put_TuneRequest(TuneRequest); ! return Result; } } } // if we get down here then the Tune Request is new so lets add it --- 766,940 ---- // Tuning Information maintenance routines /////////////////////////////////////////////////////////////////////////////// ! HRESULT CTuneRequestStore::GetGuideDataProperty(IEnumGuideDataProperties* EnumGuideDataProperties, wchar_t* PropertyName, CComVariant& PropertyValue) { HRESULT Result = S_OK; + CComPtr<IGuideDataProperty> GuideDataProperty; + ULONG Items(0); + while (EnumGuideDataProperties->Next(1, &GuideDataProperty, &Items) == S_OK) + { + CComBSTR Name; + + Result = GuideDataProperty->get_Name(&Name); + if(Name != NULL && Name == PropertyName) + { + Result = GuideDataProperty->get_Value(&PropertyValue); + return Result; + } + Name.Empty(); + GuideDataProperty.Release(); + } + PropertyValue.Clear(); + return E_FAIL; + } + + HRESULT CTuneRequestStore::GetGuideDataProperty(IEnumGuideDataProperties* EnumGuideDataProperties, wchar_t* PropertyName, CComBSTR& PropertyValue) + { + CComVariant Variant; + HRESULT Result = GetGuideDataProperty(EnumGuideDataProperties, PropertyName, Variant); + if(SUCCEEDED(Result)) + { + Result = Variant.ChangeType(VT_BSTR); + CHECK(Result); + + PropertyValue = Variant.bstrVal; + return S_OK; + } + else + { + PropertyValue.Empty(); + return Result; + } + } + + HRESULT CTuneRequestStore::GetGuideDataProperty(IEnumGuideDataProperties* EnumGuideDataProperties, wchar_t* PropertyName, ULONG& PropertyValue) + { + CComVariant Variant; + HRESULT Result = GetGuideDataProperty(EnumGuideDataProperties, PropertyName, Variant); + if(SUCCEEDED(Result)) + { + Result = Variant.ChangeType(VT_UI4); + CHECK(Result); + + PropertyValue = Variant.ulVal; + return S_OK; + } + else + { + PropertyValue = 0; + return Result; + } + } + + #define DIFF_GPS_DAYS 3657 + + HRESULT CTuneRequestStore::ConvertGPSTimeToDouble(ULONG GPSTime, double& VariantTime) + { + // **** warning **** + // all this needs to be tested + // there is no error checking yet + // and I have no idea if this will work as expected + + // convert GPS time to C time + // by adding the number of seconds between the midnights of 1/Jan/1970 to 6/Jan/1980 + // which are the starts of c time and GPS time respectively + time_t CStyleTime = DIFF_GPS_DAYS * 86400 + GPSTime; + struct tm* CStyleTimeStruct = gmtime(&CStyleTime); + + // make an NT style time + SYSTEMTIME SystemTimeUTC; + memset(&SystemTimeUTC, 0, sizeof(SystemTimeUTC)); + + SystemTimeUTC.wYear = CStyleTimeStruct->tm_year; + SystemTimeUTC.wMonth = CStyleTimeStruct->tm_mon; + SystemTimeUTC.wDay = CStyleTimeStruct->tm_mday; + SystemTimeUTC.wHour = CStyleTimeStruct->tm_hour; + SystemTimeUTC.wMinute = CStyleTimeStruct->tm_min; + SystemTimeUTC.wSecond = CStyleTimeStruct->tm_sec; + + SYSTEMTIME SystemTimeLocal; + + // convert the GPS time to local timezone + SystemTimeToTzSpecificLocalTime(NULL, &SystemTimeUTC, &SystemTimeLocal); + + // convert local time to a Variant type ready for use + SystemTimeToVariantTime(&SystemTimeLocal, &VariantTime); + + return S_OK; + } + + HRESULT CTuneRequestStore::UpdateScheduleInfo(BSTR ServiceId, BSTR ScheduleID, BSTR Title, BSTR Description, ULONG StartTime, ULONG EndTime) + { + HRESULT Result = S_OK; + + double DoubleStartTime; + double DoubleEndTime; + + Result = ConvertGPSTimeToDouble(StartTime, DoubleStartTime); + CHECK(Result); + Result = ConvertGPSTimeToDouble(EndTime, DoubleEndTime); + CHECK(Result); + + CTuneInfo* pTuneInfo = (CTuneInfo*)GetTuneInfo(ServiceId); + if(pTuneInfo != NULL) + { + for(int i(0); i < pTuneInfo->m_ProgramInfos.size(); ++i) + { + if(pTuneInfo->m_ProgramInfos[i] != NULL) + { + pTuneInfo->m_ProgramInfos[i]->put_Description(Description); + pTuneInfo->m_ProgramInfos[i]->put_Name(Title); + pTuneInfo->m_ProgramInfos[i]->put_StartTime(DoubleStartTime); + pTuneInfo->m_ProgramInfos[i]->put_EndTime(DoubleEndTime); + } + } + + CComObject<CProgramInfo>* pProgramInfo = new CComObject<CProgramInfo>; + pProgramInfo->AddRef(); + + pProgramInfo->put_Id(ScheduleID); + pProgramInfo->put_Description(Description); + pProgramInfo->put_Name(Title); + pProgramInfo->put_StartTime(DoubleStartTime); + pProgramInfo->put_EndTime(DoubleEndTime); + + pTuneInfo->m_ProgramInfos.push_back(pProgramInfo); + } + return Result; + } + + ITuneInfo* CTuneRequestStore::GetTuneInfo(BSTR ServiceId) + { for(int i(0); i < m_TuneInfos.size(); ++i) { if(m_TuneInfos[i] != NULL) { ! CComBSTR Id; ! if(FAILED(m_TuneInfos[i]->get_UniqueID(&Id))) ! { ! return NULL; ! } ! if(Id == ServiceId) { ! return m_TuneInfos[i]; } } } + return NULL; + } + + + HRESULT CTuneRequestStore::UpdateTuneRequest(BSTR Id, ITuneRequest* TuneRequest, BSTR Name) + { + HRESULT Result = S_OK; + + + ITuneInfo* pPrevTuneInfo = GetTuneInfo(Id); + if(pPrevTuneInfo != NULL) + { + Result = pPrevTuneInfo->put_TuneRequest(TuneRequest); + return Result; + } // if we get down here then the Tune Request is new so lets add it *************** *** 802,814 **** } ! HRESULT CTuneRequestStore::UpdateProgramInfo() { ! HRESULT Result = S_OK; ! if(m_GuideData == NULL || m_UpdatePending == false) { ! return S_OK; } CComQIPtr<ITuneRequestInfo> TuneRequestInfo = m_GuideData; --- 957,996 ---- } ! void CTuneRequestStore::UpdateInfo() { ! // don't update if we haven't got anything to do ! // or we can't access the TIF if(m_GuideData == NULL || m_UpdatePending == false) { ! return; } + HRESULT Result = S_OK; + + // first update all the IProgramInfo objects + // based on the current info + Result = UpdateServiceInfo(); + if(FAILED(Result)) + { + ATLTRACE("UpdateServiceInfo Failed %08x\n", Result); + return; + } + + // Then try and update the schedule info + Result = UpdateScheduleInfo(); + if(FAILED(Result)) + { + ATLTRACE("UpdateScheduleInfo Failed %08x\n", Result); + return; + } + + // clear update pending flag + m_UpdatePending = false; + } + + HRESULT CTuneRequestStore::UpdateServiceInfo() + { + HRESULT Result = S_OK; + CComQIPtr<ITuneRequestInfo> TuneRequestInfo = m_GuideData; *************** *** 836,894 **** //CHECK(TuneRequest); ! CComPtr<IEnumGuideDataProperties> EnumGuideDataProperties; ! Result = m_GuideData->GetServiceProperties(TuneRequest, &EnumGuideDataProperties); ! if(SUCCEEDED(Result)) ! { ! CComBSTR Id; ! CComBSTR Name; - CComPtr<IGuideDataProperty> GuideDataProperty; - while (EnumGuideDataProperties->Next(1, &GuideDataProperty, &Items) == S_OK) - { - BSTR PropertyName = NULL; - Result = GuideDataProperty->get_Name(&PropertyName); - if(PropertyName != NULL && wcsicmp(PropertyName, L"Description.ID") == 0) - { - CComVariant Variant; - GuideDataProperty->get_Value(&Variant); - Id = (BSTR)Variant.bstrVal; - } - else if(PropertyName != NULL && wcsicmp(PropertyName, L"Description.Name") == 0) - { - CComVariant Variant; - GuideDataProperty->get_Value(&Variant); - Name = (BSTR)Variant.bstrVal; - } - if(PropertyName != NULL) - { - SysFreeString(PropertyName); - } - GuideDataProperty.Release(); - } - if(Id.Length() > 0 && Name.Length() > 0) - { - Result = UpdateTuneRequest(Id, TuneRequest, Name); - CHECK(Result); - } - } - else - { - CHECK(Result); - } TuneRequest.Release(); } } } ! ! // clear update pending flag ! m_UpdatePending = false; ! return S_OK; } ///////////////////////////////////////////////////////////////////////////// // CVS Log // // $Log$ // Revision 1.9 2003/02/21 12:09:10 adcockj // Changed IGuideDataEvent functions to return immediately --- 1018,1113 ---- //CHECK(TuneRequest); ! CComPtr<IEnumGuideDataProperties> EnumServiceProperties; ! Result = m_GuideData->GetServiceProperties(TuneRequest, &EnumServiceProperties); ! CHECK(Result); ! ! CComBSTR Id; ! CComBSTR Name; ! ! Result = GetGuideDataProperty(EnumServiceProperties, L"Description.ID", Id); ! CHECK(Result); ! ! Result = GetGuideDataProperty(EnumServiceProperties, L"Description.Name", Name); ! CHECK(Result); ! ! Result = UpdateTuneRequest(Id, TuneRequest, Name); ! CHECK(Result); TuneRequest.Release(); } } } ! ! return Result; ! } ! ! HRESULT CTuneRequestStore::UpdateScheduleInfo() ! { ! HRESULT Result = S_OK; ! CComPtr<IEnumVARIANT> EnumScheduleEntries; ! ! Result = m_GuideData->GetScheduleEntryIDs(&EnumScheduleEntries); ! if(SUCCEEDED(Result)) ! { ! ULONG Items(0); ! CComVariant ScheduleID; ! ! while(SUCCEEDED(EnumScheduleEntries->Next(1, &ScheduleID, &Items))) ! { ! CComPtr<IEnumGuideDataProperties> EnumScheduleProperties; ! ! CComBSTR ServiceId; ! CComVariant ProgramId; ! ULONG StartTime; ! ULONG EndTime; ! ! Result = m_GuideData->GetScheduleEntryProperties(ScheduleID, &EnumScheduleProperties); ! CHECK(Result); ! ! Result = GetGuideDataProperty(EnumScheduleProperties, L"ScheduleEntry.ServiceID", ServiceId); ! CHECK(Result); ! ! Result = GetGuideDataProperty(EnumScheduleProperties, L"ScheduleEntry.ProgramID", ProgramId); ! CHECK(Result); ! ! Result = GetGuideDataProperty(EnumScheduleProperties, L"Time.Start", StartTime); ! CHECK(Result); ! ! Result = GetGuideDataProperty(EnumScheduleProperties, L"Time.End", EndTime); ! CHECK(Result); ! ! CComPtr<IEnumGuideDataProperties> EnumProgramProperties; ! ! Result = m_GuideData->GetProgramProperties(ProgramId, &EnumProgramProperties); ! CHECK(Result); ! ! CComBSTR Title; ! CComBSTR Description; ! ! Result = GetGuideDataProperty(EnumProgramProperties, L"Description.Title", Title); ! CHECK(Result); ! ! Result = GetGuideDataProperty(EnumProgramProperties, L"Description.One Sentence", Description); ! CHECK(Result); ! ! Result = UpdateScheduleInfo(ServiceId, ScheduleID.bstrVal, Title, Description, StartTime, EndTime); ! CHECK(Result); ! ! ScheduleID.Clear(); ! } ! } ! ! return Result; } + ///////////////////////////////////////////////////////////////////////////// // CVS Log // // $Log$ + // Revision 1.10 2003/02/21 16:36:43 adcockj + // Added schedule functionality (untested) and some code clean up + // // Revision 1.9 2003/02/21 12:09:10 adcockj // Changed IGuideDataEvent functions to return immediately Index: TuneRequestStore.h =================================================================== RCS file: /cvsroot/bdadev/TuneReqStore/TuneRequestStore.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TuneRequestStore.h 21 Feb 2003 12:09:10 -0000 1.8 --- TuneRequestStore.h 21 Feb 2003 16:36:44 -0000 1.9 *************** *** 2,6 **** // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that used XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// --- 2,6 ---- // $Id$ ///////////////////////////////////////////////////////////////////////////// ! // TuneReqStore - A channel storage object that uses XML to persist tune requests // Copyright (c) 2003 John Adcock. All rights reserved. ///////////////////////////////////////////////////////////////////////////// *************** *** 51,56 **** public: - STDMETHOD(DetachFromTIF)(); - STDMETHOD(AttachToTIF)(/*[in]*/ IFilterGraph* pFilterGraph); // ITuneRequestStore STDMETHOD(get__NewEnum)(/*[out, retval]*/ IEnumTuneInfo** ppUnk); --- 51,54 ---- *************** *** 59,62 **** --- 57,62 ---- STDMETHOD(Save)(/*[in]*/ BSTR FileName); STDMETHOD(Load)(/*[in]*/ BSTR FileName); + STDMETHOD(DetachFromTIF)(); + STDMETHOD(AttachToTIF)(/*[in]*/ IFilterGraph* pFilterGraph); // IPropertyBag interface *************** *** 83,89 **** HRESULT UnpopulateDOMDocument(IErrorLog* pErrorLog, ITuneInfo** ppObject, const wchar_t* ObjectName); const wchar_t* MakeTagName(int ChannelIndex); HRESULT UpdateTuneRequest(BSTR Id, ITuneRequest* TuneRequest, BSTR Name); ! HRESULT UpdateProgramInfo(); ! private: typedef std::stack<xml::IXMLDOMElement*> ElementStack; --- 83,96 ---- HRESULT UnpopulateDOMDocument(IErrorLog* pErrorLog, ITuneInfo** ppObject, const wchar_t* ObjectName); const wchar_t* MakeTagName(int ChannelIndex); + void UpdateInfo(); + HRESULT UpdateServiceInfo(); + HRESULT UpdateScheduleInfo(); HRESULT UpdateTuneRequest(BSTR Id, ITuneRequest* TuneRequest, BSTR Name); ! HRESULT GetGuideDataProperty(IEnumGuideDataProperties* EnumGuideDataProperties, wchar_t* PropertyName, CComBSTR& PropertyValue); ! HRESULT GetGuideDataProperty(IEnumGuideDataProperties* EnumGuideDataProperties, wchar_t* PropertyName, CComVariant& PropertyValue); ! HRESULT GetGuideDataProperty(IEnumGuideDataProperties* EnumGuideDataProperties, wchar_t* PropertyName, ULONG& PropertyValue); ! HRESULT ConvertGPSTimeToDouble(ULONG GPSTime, double& DoubleTime); ! HRESULT UpdateScheduleInfo(BSTR ServiceId, BSTR ScheduleID, BSTR Title, BSTR Description, ULONG StartTime, ULONG EndTime); ! ITuneInfo* GetTuneInfo(BSTR ServiceId); private: typedef std::stack<xml::IXMLDOMElement*> ElementStack; |