unit sendevtSvr;
interface
uses
OleAuto,
Ole2,
Windows,
Registry,
sendevtC3PO,
Dialogs,
C3poinc;
type
C3POServer = class(TC3POServer)
private
function GetCmdFact: Variant;
function GetDescription : string;
function GetEventMonitor : variant;
function GetIconFactory : variant;
automated
property CommandFactory : Variant read GetCmdFact;
property Description: string read GetDescription;
property EventMonitor: variant read GetEventMonitor;
property IconFactory: variant read GetIconFactory;
function CanShutdown: TOleBool;
procedure DeInit;
procedure Init(Manager: variant);
end;
function RegisterServer : HResult;
function DllUnregisterServer : HResult;
function GWEventNotify (dwID : Cardinal; dwNotification : Cardinal): longint export stdcall;
exports
DllGetClassObject index 1,
DllCanUnloadNow index 2,
DllRegisterServer index 3 name 'DllRegisterServer',
DllUnregisterServer index 4 name 'DllUnregisterServer',
GWEventNotify index 5 name 'GWEventNotify';
implementation
var
g_CommandFactory : CommandFactory;
g_IconFactory : IconFactory;
g_EventMonitor : EventMonitor;
function C3POServer.GetCmdFact : Variant;
class='delphiKeyword'>begin
Result := g_CommandFactory.OleObject;
end;
function C3POServer.GetDescription : string;
class='delphiKeyword'>begin
Result := 'Put any comment here you want';
end;
function C3POServer.GetEventMonitor : Variant;
class='delphiKeyword'>begin
Result := g_EventMonitor.OleObject;
end;
is not in a state where shutdown
is possible. Each C3PO server is guaranteed to have CanShutdown
queried at least once before the C3PO system shuts down.
Semantically, CanShutdown is a request from the C3POManager to
a given C3PO. It's not a request for shutting down a C3PO class='delphiKeyword'>as
much class='delphiKeyword'>as it is a request to shutdown the C3POManager class='delphiKeyword'>and consequently
disconnect the C3PO. Typically, a C3PO would shutdown along
with the C3POManager, but this is not strictly required.
No particular C3PO order can be relied on for querying the CanShutdown property.
In: none
Out: TRUE if it is OK to shutdown
FALSE if it is not OK to shutdown
Comments:
************************************************************}
function C3POServer.CanShutdown: TOleBool;
class='delphiKeyword'>begin
Result := TRUE;
end;
function C3POServer.GetIconFactory : Variant;
class='delphiKeyword'>begin
Result := g_IconFactory.OleObject;
end;
a runtime optimization. In that
scenario, the C3PO server first receives CanShutdown() calls
followed by DeInit() – the C3PO is unloaded, but the client
application has not necessarilly terminated.
The C3POManager pointer passed in to C3POServer::Init() is
still valid during this call. However, when DeInit() returns,
the C3POManager pointer is not guaranteed to be valid. The
C3POServer must release all holds to the C3POManager during
the DeInit call.
One DeInit call will be issued to the C3POServer for each C3PO
Client using the C3PO system. C3POs that wish to be capable of
loading into multiple Clients (irrespective of process boundaries)
should be multiple-instance OLE servers. That is, a new C3POServer
object should be created for each C3POManager that wished to
use the services of the C3PO. By tracking the Manager pointer
for each C3POServer, the C3PO can sort out which requests are
being issued from which clients.
In: none
Out: none
Comments:
************************************************************}
procedure C3POServer.DeInit;
class='delphiKeyword'>begin
g_C3POManager := unassigned;
end;
procedure C3POServer.Init(Manager: variant);
class='delphiKeyword'>begin
g_C3POManager := Manager;
OleInitialize(Nil);
end;
procedure RegisterC3POServer;
const
AutoClassInfo: TAutoClassInfo = (
AutoClass: C3POServer;
ProgID: 'sendevt';
ClassID: '';
Description: 'C3po Automation';
Instancing: acMultiInstance);
class='delphiKeyword'>begin
Automation.RegisterClass(AutoClassInfo);
RegisterServer;
end;
is used by the
client in response to events requested by this
C3PO for a compose view.
In: dwID: 32 bit value passed to the GW client class='delphiKeyword'>as part
of the EventNoticeRegister token. This can be an ID
or a pointer to memory needed by this routine.
dwNotification: Flag indicating which event has taken place.
EVT_GROUPWISE_SEND_ITEM = $1;
EVT_GROUPWISE_CANCEL_ITEM = $2;
EVT_GROUPWISE_CLOSE_ITEM = $4;
EVT_GROUPWISE_PACKAGING_ITEM = $8;
EVT_GROUPWISE_PACKAGING_ITEM_CANCELED = $10;
EVT_GROUPWISE_SEND_ITEM_COMPLETED = $20;
Out: None
Comments:
************************************************************}
function GWEventNotify (dwID : Cardinal; dwNotification : Cardinal): longint; export stdcall;
var
iDDEReturn : integer;
sReturn : string;
sMessage : string;
iMsgRet : integer;
lFncRet : longint;
class='delphiKeyword'>begin
lFncRet := 0;
class='delphiKeyword'>case dwNotification of
EVT_GROUPWISE_SEND_ITEM:
class='delphiKeyword'>begin
sReturn := 'EVT_GROUPWISE_SEND_ITEM received';
end;
EVT_GROUPWISE_CANCEL_ITEM:
class='delphiKeyword'>begin
sReturn := 'EVT_GROUPWISE_CANCEL_ITEM received';
end;
EVT_GROUPWISE_CLOSE_ITEM:
class='delphiKeyword'>begin
sReturn := 'EVT_GROUPWISE_CLOSE_ITEM received';
end;
EVT_GROUPWISE_PACKAGING_ITEM:
class='delphiKeyword'>begin
sReturn := 'EVT_GROUPWISE_PACKAGING_ITEM received';
iMsgRet := MessageDlg ('Send Message?', mtInformation, [mbYes, mbNo], 0);
if iMsgRet = IDNO then lFncRet := -1;
end;
EVT_GROUPWISE_PACKAGING_ITEM_CANCELED:
class='delphiKeyword'>begin
sReturn := 'EVT_GROUPWISE_PACKAGING_ITEM_CANCELLED received';
end;
EVT_GROUPWISE_SEND_ITEM_COMPLETED:
class='delphiKeyword'>begin
sReturn := 'EVT_GROUPWISE_SEND_ITEM_COMPLETED received';
end;
end;
MessageDlg (sReturn, mtInformation, [mbOk], 0);
GWEventNotify := lFncRet;
end;
function RegisterServer : HResult;
var
Reg : TRegistry;
sRegKeyName : string [120];
sAppName : string [120];
class='delphiKeyword'>begin
sAppName := 'sendevt';
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE;
sRegKeyName := '\SOFTWARE\Novell\GroupWise\5.0\C3PO\DataTypes\GW.CLIENT\sendevt';
Reg.OpenKey (sRegKeyName, TRUE);
Reg.OpenKey ('Objects', TRUE);
Reg.WriteString ('EventMonitor', '');
Reg.OpenKey (sRegKeyName, TRUE);
Reg.OpenKey ('Events', TRUE);
Reg.WriteString ('OnReady', '');
Reg.WriteString ('OnShutdown', '');
sRegKeyName := '\SOFTWARE\Novell\GroupWise\5.0\C3PO\DataTypes\GW.MESSAGE.MAIL\sendevt';
Reg.OpenKey (sRegKeyName, TRUE);
Reg.OpenKey ('Objects', TRUE);
Reg.WriteString ('CommandFactory', '');
Reg.OpenKey (sRegKeyName, TRUE);
Reg.OpenKey ('Events', TRUE);
Reg.WriteString (eGW_CMDID_COMPOSE, '');
Result := S_OK;
end;
function DllUnregisterServer : HResult;
var
Reg : TRegistry;
sRegKeyName : string [120];
sAppName : string [120];
class='delphiKeyword'>begin
sAppName := 'sendevt';
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE;
sRegKeyName := '\SOFTWARE\Novell\GroupWise\5.0\C3PO\DataTypes\GW.CLIENT\sendevt';
Reg.DeleteKey(sRegKeyName);
sRegKeyName := '\SOFTWARE\Novell\GroupWise\5.0\C3PO\DataTypes\GW.MESSAGE.MAIL\sendevt';
Reg.DeleteKey(sRegKeyName);
Result := S_OK;
end;
initialization
class='delphiKeyword'>begin
RegisterC3POServer;
g_CommandFactory := CommandFactory.Create;
g_IconFactory := IconFactory.Create;
g_EventMonitor := EventMonitor.Create;
end;
finalization
class='delphiKeyword'>begin
g_CommandFactory.Release;
g_IconFactory.Release;
g_EventMonitor.Release;
end;
end.