sync master with lastest vba changes
[ooovba.git] / goodies / inc / chlist.hxx
blobd669ce29194242f079da8e1f50602ab8d060c29e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chlist.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CHLIST_HXX
32 #define _CHLIST_HXX
34 #include <tools/urlobj.hxx>
35 #include <tools/datetime.hxx>
36 #include <tools/string.hxx>
37 #include <vcl/timer.hxx>
38 #include <tools/list.hxx>
39 #ifndef _INETSES_HXX //autogen
40 #include <inet/inetsess.hxx>
41 #endif
43 class Downloader;
44 class ChannelAgentItem;
45 class ChannelItem;
46 class ChannelItemList;
47 class ChannelAgentItemList;
48 class ChannelTuner;
49 class ChannelApi;
50 class GetChannelObj;
51 class GetChObjList;
52 class NotifyItem;
53 class Date;
54 class Time;
55 class ResMgr;
57 struct UiAgentItem
59 String aName;
60 ULONG aUpdPeriode;
61 DateTime aLastDataDate;
62 DateTime aLastUpdDate;
63 BOOL bUnregister;
64 BOOL bIsEnabled;
67 DECLARE_LIST(UiAgentList, UiAgentItem*)
68 DECLARE_LIST(NotifyList, NotifyItem*)
70 #ifndef STRING_LIST
71 #define STRING_LIST
72 #define _TOOLS_STRINGLIST
73 #include <tools/sstring.hxx>
74 #endif
76 ///////////////////////////////////////////////////////////////////////////////
79 #define JOBID_DOWNLOAD_AGENT 1
80 #define JOBID_UPDATE_AGENT 2
81 #define JOBID_CHECK_TRANSMITTER 3
83 struct BTXResponse
85 USHORT nJobId;
86 BOOL bFinish;
87 ULONG nTransferStatus;
88 String aLocalFileName;
91 ///////////////////////////////////////////////////////////////////////////////
94 class ChannelList
96 ResMgr* pResMgr;
97 ChannelAgentItemList* pAgentList;
98 ChannelItemList* pChannelList;
99 NotifyList* pNotifyList;
100 GetChObjList* pGetChObjList;
101 UiAgentList* pUiAgentList;
103 ChannelTuner* pChannelTuner;
105 String aAgentPath;
106 AutoTimer aTimer;
107 INetSessionRef xINetSession;
109 Link aNotifyPermissionHdl;
110 Link aCheckFinishHdl;
111 // wird von der ChannelList gehandelt; sollte ausgebaut werden; auch im SFX
112 Link aAgentUpdateHdl;
113 Downloader* pBTXDecoder;
115 void MakeGodChannel(ChannelAgentItem* pAgent);
116 void DeleteUiAgentList();
118 BOOL StartAgent(ChannelAgentItem* pAgent);
120 void DoNotifyAgents();
121 void NotifyAgent(ChannelAgentItem* pAgent, ULONG nNotifyItemIdx);
123 void UpdateAgent(ChannelAgentItem* pAgent, ULONG nNotifyItemIdx);
124 void SendItemToTuner(ChannelItem* pItem);
126 BOOL ParseDateTime(const String& rSrc, Date& rDate, Time& rTime);
128 void UnZipAgent(ChannelAgentItem* pAgent);
129 static void EnumFilesCallBack(char *pFile, void *pObject);
131 DECL_LINK(CheckChannels, void*);
132 DECL_LINK(CloseChannelObjEvt, void*);
133 DECL_LINK(GetChannelObjNotify, GetChannelObj*);
134 protected:
135 friend class ChannelApi;
136 friend class ChannelTuner;
138 ChannelItem* GetChannelItemByName(const String& rName);
139 ChannelAgentItem* GetAgentItemByName(const String& rName);
141 void ReadChannelList();
142 void ReadAgentList();
143 void WriteChannelItem(ChannelItem* pItem);
144 void WriteAgentItem(ChannelAgentItem* pChAgent);
145 void SetLastSuccUpdChannel(ChannelAgentItem* pChAgent);
146 void SetLastSuccUpdAgent(ChannelAgentItem* pChAgent);
147 void SetEnabledAgent(ChannelAgentItem* pChAgent);
149 void DeleteAgentItem(ChannelAgentItem* pItem);
150 void DeleteChannelItem(ChannelItem* pItem);
151 void RegisterNewChannelItem(ChannelItem* pItem);
153 void CancelBTX();
154 Downloader* GetBTXDecoder() const { return pBTXDecoder; }
155 ResMgr* GetResMgr() const { return pResMgr; }
157 DECL_LINK(CheckBTXFinishHdl, void*);
159 void NotifyTransmitterMsg(const String& rStr);
161 public:
162 ChannelList(const String& rAgentPath);
163 ~ChannelList();
165 void SubscribeNewAgent(const INetURLObject& rURL);
167 void SetINetSession(INetSession* pNewSess);
168 void SetBTXDecoder(Downloader* pDecoder);
170 void SetNotifyPermissionHdl(const Link& rHdl) { aNotifyPermissionHdl = rHdl; }
171 void SetAgentUpdateHdl(const Link& rHdl) { aAgentUpdateHdl = rHdl; }
173 void SetTimerInterval(ULONG nNew);
174 void StartCheckChannels();
175 void StopCheckChannels();
177 void CheckAgentNow(const String& rAgName, BOOL bCheckGOD = FALSE);
178 void SetCheckFinishHdl(const Link& rHdl) { aCheckFinishHdl = rHdl; }
179 const Link& GetCheckFinishHdl() const { return aCheckFinishHdl;};
181 UiAgentList* GetUiAgentList();
182 void JoinUiAgentList();
185 ///////////////////////////////////////////////////////////////////////////////
188 class NotifyItem
190 ChannelItem* pChItem;
192 USHORT nGMTOffset;
193 ULONG nDateLastUpd;
194 long nTimeLastUpd;
195 INetURLObject aChObjURL;
196 String aChName;
197 public:
198 NotifyItem( ChannelItem* pItem, short nGMTOff, ULONG nLastDate,
199 ULONG nLastTime, const INetURLObject& rChObjURL,
200 const String& rChName);
201 ~NotifyItem();
203 ChannelItem* GetChannelItem() const { return pChItem; }
205 const String& GetChannelName() const { return aChName; }
206 const INetURLObject GetChannelObjURL() const { return aChObjURL; }
208 void SetDateLastUpd(ULONG nNew) { nDateLastUpd = nNew; }
209 ULONG GetDateLastUpd() const { return nDateLastUpd; }
211 void SetTimeLastUpd(long nNew) { nTimeLastUpd = nNew; }
212 long GetTimeLastUpd() const { return nTimeLastUpd; }
214 const String& GetChAgentName() const;
218 #endif // _CHLIST_HXX