From cb4a46e7fbe62d788e66ed6121c717a2d22a4d7c Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 21 Apr 2011 14:14:52 +0000 Subject: svn.miranda.im is moving to a new home! git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- newstatusnotify/ExternalAPI/m_metacontacts.h | 162 +++++++++++++++++++++++++++ newstatusnotify/ExternalAPI/m_updater.h | 117 +++++++++++++++++++ 2 files changed, 279 insertions(+) create mode 100644 newstatusnotify/ExternalAPI/m_metacontacts.h create mode 100644 newstatusnotify/ExternalAPI/m_updater.h (limited to 'newstatusnotify/ExternalAPI') diff --git a/newstatusnotify/ExternalAPI/m_metacontacts.h b/newstatusnotify/ExternalAPI/m_metacontacts.h new file mode 100644 index 0000000..1da12b9 --- /dev/null +++ b/newstatusnotify/ExternalAPI/m_metacontacts.h @@ -0,0 +1,162 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright © 2004 Universite Louis PASTEUR, STRASBOURG. +Copyright © 2004 Scott Ellis (www.scottellis.com.au mail@scottellis.com.au) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program 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. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef M_METACONTACTS_H__ +#define M_METACONTACTS_H__ 1 + +//get the handle for a contact's parent metacontact +//wParam=(HANDLE)hSubContact +//lParam=0 +//returns a handle to the parent metacontact, or null if this contact is not a subcontact +#define MS_MC_GETMETACONTACT "MetaContacts/GetMeta" + +//gets the handle for the default contact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a handle to the default contact, or null on failure +#define MS_MC_GETDEFAULTCONTACT "MetaContacts/GetDefault" + +//gets the contact number for the default contact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a DWORD contact number, or -1 on failure +#define MS_MC_GETDEFAULTCONTACTNUM "MetaContacts/GetDefaultNum" + +//gets the handle for the 'most online' contact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a handle to the 'most online' contact +#define MS_MC_GETMOSTONLINECONTACT "MetaContacts/GetMostOnline" + +//gets the number of subcontacts for a metacontact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a DWORD representing the number of subcontacts for the given metacontact +#define MS_MC_GETNUMCONTACTS "MetaContacts/GetNumContacts" + +//gets the handle of a subcontact, using the subcontact's number +//wParam=(HANDLE)hMetaContact +//lParam=(DWORD)contact number +//returns a handle to the specified subcontact +#define MS_MC_GETSUBCONTACT "MetaContacts/GetSubContact" + +//sets the default contact, using the subcontact's contact number +//wParam=(HANDLE)hMetaContact +//lParam=(DWORD)contact number +//returns 0 on success +#define MS_MC_SETDEFAULTCONTACTNUM "MetaContacts/SetDefault" + +//sets the default contact, using the subcontact's handle +//wParam=(HANDLE)hMetaContact +//lParam=(HANDLE)hSubcontact +//returns 0 on success +#define MS_MC_SETDEFAULTCONTACT "MetaContacts/SetDefaultByHandle" + +//forces the metacontact to send using a specific subcontact, using the subcontact's contact number +//wParam=(HANDLE)hMetaContact +//lParam=(DWORD)contact number +//returns 0 on success +#define MS_MC_FORCESENDCONTACTNUM "MetaContacts/ForceSendContact" + +//forces the metacontact to send using a specific subcontact, using the subcontact's handle +//wParam=(HANDLE)hMetaContact +//lParam=(HANDLE)hSubcontact +//returns 0 on success (will fail if 'force default' is in effect) +#define MS_MC_FORCESENDCONTACT "MetaContacts/ForceSendContactByHandle" + +//'unforces' the metacontact to send using a specific subcontact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns 0 on success (will fail if 'force default' is in effect) +#define MS_MC_UNFORCESENDCONTACT "MetaContacts/UnforceSendContact" + +//'forces' or 'unforces' (i.e. toggles) the metacontact to send using it's default contact +// overrides (and clears) 'force send' above, and will even force use of offline contacts +// will send ME_MC_FORCESEND or ME_MC_UNFORCESEND event +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns 1(true) or 0(false) representing new state of 'force default' +#define MS_MC_FORCEDEFAULT "MetaContacts/ForceSendDefault" + +// method to get state of 'force' for a metacontact +// wParam=(HANDLE)hMetaContact +// lParam= (DWORD)&contact_number or NULL +// +// if lparam supplied, the contact_number of the contatct 'in force' will be copied to the address it points to, +// or if none is in force, the value (DWORD)-1 will be copied +// (v0.8.0.8+ returns 1 if 'force default' is true with *lParam == default contact number, else returns 0 with *lParam as above) +#define MS_MC_GETFORCESTATE "MetaContacts/GetForceState" + +// fired when a metacontact's default contact changes (fired upon creation of metacontact also, when default is initially set) +// wParam=(HANDLE)hMetaContact +// lParam=(HANDLE)hDefaultContact +#define ME_MC_DEFAULTTCHANGED "MetaContacts/DefaultChanged" + +// fired when a metacontact's subcontacts change (fired upon creation of metacontact, when contacts are added or removed, and when +// contacts are reordered) - a signal to re-read metacontact data +// wParam=(HANDLE)hMetaContact +// lParam=0 +#define ME_MC_SUBCONTACTSCHANGED "MetaContacts/SubcontactsChanged" + +// fired when a metacontact is forced to send using a specific subcontact +// wParam=(HANDLE)hMetaContact +// lParam=(HANDLE)hForceContact +#define ME_MC_FORCESEND "MetaContacts/ForceSend" + +// fired when a metacontact is 'unforced' to send using a specific subcontact +// wParam=(HANDLE)hMetaContact +// lParam=0 +#define ME_MC_UNFORCESEND "MetaContacts/UnforceSend" + +// method to get protocol name - used to be sure you're dealing with a "real" metacontacts plugin :) +// wParam=lParam=0 +#define MS_MC_GETPROTOCOLNAME "MetaContacts/GetProtoName" + + +// added 0.9.5.0 (22/3/05) +// wParam=(HANDLE)hContact +// lParam=0 +// convert a given contact into a metacontact +#define MS_MC_CONVERTTOMETA "MetaContacts/ConvertToMetacontact" + +// added 0.9.5.0 (22/3/05) +// wParam=(HANDLE)hContact +// lParam=(HANDLE)hMeta +// add an existing contact to a metacontact +#define MS_MC_ADDTOMETA "MetaContacts/AddToMetacontact" + +// added 0.9.5.0 (22/3/05) +// wParam=0 +// lParam=(HANDLE)hContact +// remove a contact from a metacontact +#define MS_MC_REMOVEFROMMETA "MetaContacts/RemoveFromMetacontact" + + +// added 0.9.13.2 (6/10/05) +// wParam=(BOOL)disable +// lParam=0 +// enable/disable the 'hidden group hack' - for clists that support subcontact hiding using 'IsSubcontact' setting +// should be called once in the clist 'onmodulesloaded' event handler (which, since it's loaded after the db, will be called +// before the metacontact onmodulesloaded handler where the subcontact hiding is usually done) +#define MS_MC_DISABLEHIDDENGROUP "MetaContacts/DisableHiddenGroup" + +#endif diff --git a/newstatusnotify/ExternalAPI/m_updater.h b/newstatusnotify/ExternalAPI/m_updater.h new file mode 100644 index 0000000..c83b8a4 --- /dev/null +++ b/newstatusnotify/ExternalAPI/m_updater.h @@ -0,0 +1,117 @@ +#ifndef _M_UPDATER_H +#define _M_UPDATER_H + +// if you set Update::szUpdateURL to the following value when registering, as well as setting your beta site and version data, +// updater will ignore szVersionURL and pbVersionPrefix, and attempt to find the file listing URL's from the backend XML data. +// for this to work, the plugin name in pluginInfo.shortName must match the file listing exactly (except for case) +#define UPDATER_AUTOREGISTER "UpdaterAUTOREGISTER" + +typedef struct Update_tag { + int cbSize; + char *szComponentName; // component name as it will appear in the UI (will be translated before displaying) + + char *szVersionURL; // URL where the current version can be found (NULL to disable) + BYTE *pbVersionPrefix; // bytes occuring in VersionURL before the version, used to locate the version information within the URL data + // (not that this URL could point at a binary file - dunno why, but it could :) + int cpbVersionPrefix; // number of bytes pionted to by pbVersionPrefix + char *szUpdateURL; // URL where dll/zip is located + // set to UPDATER_AUTOREGISTER if you want updater to find the file listing URLs (ensure plugin shortName matches file listing!) + + char *szBetaVersionURL; // URL where the beta version can be found (NULL to disable betas) + BYTE *pbBetaVersionPrefix; // bytes occuring in VersionURL before the version, used to locate the version information within the URL data + int cpbBetaVersionPrefix; // number of bytes pionted to by pbVersionPrefix + char *szBetaUpdateURL; // URL where dll/zip is located + + BYTE *pbVersion; // bytes of current version, used for comparison with those in VersionURL + int cpbVersion; // number of bytes pionted to by pbVersion + + char *szBetaChangelogURL; // url for displaying changelog for beta versions +} Update; + +// register a comonent with the updater +// +// wparam = 0 +// lparam = (LPARAM)&Update +#define MS_UPDATE_REGISTER "Update/Register" + +// utility functions to create a version string from a DWORD or from pluginInfo +// point buf at a buffer at least 16 chars wide - but note the version string returned may be shorter +// +__inline static char *CreateVersionString(DWORD version, char *buf) { + mir_snprintf(buf, 16, "%d.%d.%d.%d", (version >> 24) & 0xFF, (version >> 16) & 0xFF, (version >> 8) & 0xFF, version & 0xFF); + return buf; +} + +__inline static char *CreateVersionStringPlugin(PLUGININFO *pluginInfo, char *buf) { + return CreateVersionString(pluginInfo->version, buf); +} + + +// register the 'easy' way - use this method if you have no beta URL and the plugin is on the miranda file listing +// NOTE: the plugin 'short name' in pluginInfo must match the name of the plugin on the file listing, exactly (not including case) +// AND the plugin version string on the file listing must be the string version of the version in pluginInfo (i.e. 0.0.0.1, +// so no letters, brackets, etc.) +// +// wParam = (int)fileID - this is the file ID from the file listing (i.e. the number at the end of the download link) +// lParam = (PLUGININFO*)&pluginInfo +#define MS_UPDATE_REGISTERFL "Update/RegisterFL" + +// this event is fired when the startup process is complete, but NOT if a restart is imminent +// it is designed for status managment plugins to use as a trigger for beggining their own startup process +// wParam = lParam = 0 (unused) +// (added in version 0.1.6.0) +#define ME_UPDATE_STARTUPDONE "Update/StartupDone" + +// this service can be used to enable/disable Updater's global status control +// it can be called from the StartupDone event handler +// wParam = (BOOL)enable +// lParam = 0 +// (added in version 0.1.6.0) +#define MS_UPDATE_ENABLESTATUSCONTROL "Update/EnableStatusControl" + +// An description of usage of the above service and event: +// Say you are a status control plugin that normally sets protocol or global statuses in your ModulesLoaded event handler. +// In order to make yourself 'updater compatible', you would move the status control code from ModulesLoaded to another function, +// say DoStartup. Then, in ModulesLoaded you would check for the existence of the MS_UPDATE_ENABLESTATUSCONTROL service. +// If it does not exist, call DoStartup. If it does exist, hook the ME_UPDATE_STARTUPDONE event and call DoStartup from there. You may +// also wish to call MS_UPDATE_ENABLESTATUSCONTROL with wParam == FALSE at this time, to disable Updater's own status control feature. + +#endif + + +/////////////// Usage Example /////////////// + +#ifdef EXAMPLE_CODE + +// you need to #include "m_updater.h" and HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded) in your Load function... + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { + + Update update = {0}; // for c you'd use memset or ZeroMemory... + char szVersion[16]; + + update.cbSize = sizeof(Update); + + update.szComponentName = pluginInfo.shortName; + update.pbVersion = (BYTE *)CreateVersionString(&pluginInfo, szVersion); + update.cpbVersion = strlen((char *)update.pbVersion); + + // these are the three lines that matter - the archive, the page containing the version string, and the text (or data) + // before the version that we use to locate it on the page + // (note that if the update URL and the version URL point to standard file listing entries, the backend xml + // data will be used to check for updates rather than the actual web page - this is not true for beta urls) + update.szUpdateURL = "http://scottellis.com.au:81/test/updater.zip"; + update.szVersionURL = "http://scottellis.com.au:81/test/updater_test.html"; + update.pbVersionPrefix = (BYTE *)"Updater version "; + + update.cpbVersionPrefix = strlen((char *)update.pbVersionPrefix); + + CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update); + + // Alternatively, to register a plugin with e.g. file ID 2254 on the file listing... + // CallService(MS_UPDATE_REGISTERFL, (WPARAM)2254, (LPARAM)&pluginInfo); + + return 0; +} + +#endif -- cgit v1.2.3