diff options
author | George Hazan <george.hazan@gmail.com> | 2014-02-22 21:33:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-02-22 21:33:42 +0000 |
commit | e1c1c7c4b0703bea2acfe2921e9351aa099a3c64 (patch) | |
tree | 033907d2135c06d74d99a0e3d523c07452c7866e /plugins/StatusPlugins | |
parent | ea9e4b0622f1c2ec9a3cc0b2b8bc5828108dd620 (diff) |
NAS support returned back to status plugins
git-svn-id: http://svn.miranda-ng.org/main/trunk@8226 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/StatusPlugins')
-rw-r--r-- | plugins/StatusPlugins/AdvancedAutoAway/version.h | 3 | ||||
-rw-r--r-- | plugins/StatusPlugins/KeepStatus/version.h | 2 | ||||
-rw-r--r-- | plugins/StatusPlugins/StartupStatus/startupstatus.cpp | 20 | ||||
-rw-r--r-- | plugins/StatusPlugins/StartupStatus/version.h | 2 | ||||
-rw-r--r-- | plugins/StatusPlugins/commonstatus.cpp | 122 | ||||
-rw-r--r-- | plugins/StatusPlugins/commonstatus.h | 1 |
6 files changed, 81 insertions, 69 deletions
diff --git a/plugins/StatusPlugins/AdvancedAutoAway/version.h b/plugins/StatusPlugins/AdvancedAutoAway/version.h index 913661c996..19a1c2e0de 100644 --- a/plugins/StatusPlugins/AdvancedAutoAway/version.h +++ b/plugins/StatusPlugins/AdvancedAutoAway/version.h @@ -2,7 +2,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 8
#define __RELEASE_NUM 1
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
// other stuff for Version resource
#include <stdver.h>
@@ -15,4 +15,3 @@ #define __AUTHOREMAIL "unregistered@users.sourceforge.net"
#define __AUTHORWEB "http://miranda-ng.org/p/AdvancedAutoAway/"
#define __COPYRIGHT "(c) 2003-08 P. Boon, 2008-11 George Hazan"
-
diff --git a/plugins/StatusPlugins/KeepStatus/version.h b/plugins/StatusPlugins/KeepStatus/version.h index 043fb3241f..4b717ddc63 100644 --- a/plugins/StatusPlugins/KeepStatus/version.h +++ b/plugins/StatusPlugins/KeepStatus/version.h @@ -2,7 +2,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 9
#define __RELEASE_NUM 0
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
// other stuff for Version resource
#include <stdver.h>
diff --git a/plugins/StatusPlugins/StartupStatus/startupstatus.cpp b/plugins/StatusPlugins/StartupStatus/startupstatus.cpp index 1483286278..2d4ca5b7fe 100644 --- a/plugins/StatusPlugins/StartupStatus/startupstatus.cpp +++ b/plugins/StatusPlugins/StartupStatus/startupstatus.cpp @@ -228,7 +228,7 @@ static int StatusChange(WPARAM wParam, LPARAM lParam) if ( !db_get_b(NULL, MODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0 )
return 0;
- char* szProto = (char *)lParam;
+ char *szProto = (char *)lParam;
if (szProto == NULL) { // global status change
for ( int i=0; i < startupSettings.getCount(); i++ ) {
startupSettings[i].szName = "";
@@ -307,9 +307,23 @@ static int OnOkToExit(WPARAM, LPARAM) if ( !(CallProtoService(pa->szModuleName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(status)))
continue;
- } }
- if ( (db_get_b(NULL, MODULENAME, SETTING_SETPROFILE, 1)) || (db_get_b(NULL, MODULENAME, SETTING_OFFLINECLOSE, 0))) {
+ // NewAwaySys
+ if (ServiceExists(MS_NAS_GETSTATE)) {
+ NAS_PROTOINFO npi = { sizeof(npi) };
+ npi.szProto = protos[i]->szModuleName;
+ CallService(MS_NAS_GETSTATE, (WPARAM)&npi, 1);
+ if (npi.szMsg == NULL) {
+ npi.status = 0;
+ npi.szProto = NULL;
+ CallService(MS_NAS_GETSTATE, (WPARAM)&npi, 1);
+ }
+ if (npi.szMsg != NULL) {
+ db_set_ts(NULL, MODULENAME, lastMsg, npi.tszMsg);
+ mir_free(npi.tszMsg);
+ } } } }
+
+ if (db_get_b(NULL, MODULENAME, SETTING_SETPROFILE, 1) || db_get_b(NULL, MODULENAME, SETTING_OFFLINECLOSE, 0)) {
if (ServiceExists(MS_CLIST_SETSTATUSMODE))
CallService(MS_CLIST_SETSTATUSMODE, (WPARAM)ID_STATUS_OFFLINE, 0);
else
diff --git a/plugins/StatusPlugins/StartupStatus/version.h b/plugins/StatusPlugins/StartupStatus/version.h index 0602c5cfca..53bc3fcd85 100644 --- a/plugins/StatusPlugins/StartupStatus/version.h +++ b/plugins/StatusPlugins/StartupStatus/version.h @@ -8,7 +8,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 8
#define __RELEASE_NUM 0
-#define __BUILD_NUM 45
+#define __BUILD_NUM 46
// other stuff for Version resource
#include <stdver.h>
diff --git a/plugins/StatusPlugins/commonstatus.cpp b/plugins/StatusPlugins/commonstatus.cpp index 361b7df6a2..20a17b151a 100644 --- a/plugins/StatusPlugins/commonstatus.cpp +++ b/plugins/StatusPlugins/commonstatus.cpp @@ -23,10 +23,10 @@ // handles for hooks and other Miranda thingies
static HANDLE hCSStatusChangedExEvent;
-OBJLIST<PROTOCOLSETTINGEX>* protoList;
+OBJLIST<PROTOCOLSETTINGEX> *protoList;
// prototypes
-char *StatusModeToDbSetting(int status,const char *suffix);
+char* StatusModeToDbSetting(int status,const char *suffix);
DWORD StatusModeToProtoFlag(int status);
INT_PTR SetStatusEx(WPARAM wParam, LPARAM lParam);
int InitCommonStatus();
@@ -79,14 +79,14 @@ DWORD StatusModeToProtoFlag(int status) int GetActualStatus(PROTOCOLSETTINGEX *protoSetting)
{
if (protoSetting->status == ID_STATUS_LAST) {
- if ( (protoSetting->lastStatus < MIN_STATUS) || (protoSetting->lastStatus > MAX_STATUS))
+ if ((protoSetting->lastStatus < MIN_STATUS) || (protoSetting->lastStatus > MAX_STATUS))
return CallProtoService(protoSetting->szName, PS_GETSTATUS, 0, 0);
return protoSetting->lastStatus;
}
if (protoSetting->status == ID_STATUS_CURRENT)
return CallProtoService(protoSetting->szName, PS_GETSTATUS, 0, 0);
- if ( (protoSetting->status < ID_STATUS_OFFLINE) || (protoSetting->status > ID_STATUS_OUTTOLUNCH)) {
+ if ((protoSetting->status < ID_STATUS_OFFLINE) || (protoSetting->status > ID_STATUS_OUTTOLUNCH)) {
log_debugA("invalid status detected: %d", protoSetting->status);
return 0;
}
@@ -94,7 +94,7 @@ int GetActualStatus(PROTOCOLSETTINGEX *protoSetting) }
// helper, from core
-static TCHAR *GetDefaultMessage(int status)
+static TCHAR* GetDefaultMessage(int status)
{
switch(status) {
case ID_STATUS_AWAY: return TranslateT("I've been away since %time%.");
@@ -112,29 +112,29 @@ static TCHAR *GetDefaultMessage(int status) return NULL;
}
-TCHAR *GetDefaultStatusMessage(PROTOCOLSETTINGEX *ps, int newstatus)
+TCHAR* GetDefaultStatusMessage(PROTOCOLSETTINGEX *ps, int newstatus)
{
if (ps->szMsg != NULL) {// custom message set
log_infoA("CommonStatus: Status message set by calling plugin");
- return mir_tstrdup( ps->szMsg );
+ return mir_tstrdup(ps->szMsg);
}
- if ( ServiceExists( MS_AWAYMSG_GETSTATUSMSGT )) {
- TCHAR* tMsg = ( TCHAR* )CallService(MS_AWAYMSG_GETSTATUSMSGT, newstatus, (LPARAM)ps->szName );
+ if (ServiceExists(MS_AWAYMSG_GETSTATUSMSGT)) {
+ TCHAR* tMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, newstatus, (LPARAM)ps->szName);
log_debugA("CommonStatus: Status message retrieved from general awaysys (TCHAR)");
return tMsg;
}
- if ( ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) {
+ if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) {
char *tMsg;
- if ( ServiceExists(MS_SA_ISSARUNNING) && CallService(MS_SA_ISSARUNNING, 0, 0))
+ if (ServiceExists(MS_SA_ISSARUNNING) && CallService(MS_SA_ISSARUNNING, 0, 0))
tMsg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)newstatus, (LPARAM)ps->szName);
else
- tMsg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)newstatus, 0);
+ tMsg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)newstatus, 0);
log_debugA("CommonStatus: Status message retrieved from general awaysys");
- TCHAR* result = mir_a2t( tMsg );
+ TCHAR* result = mir_a2t(tMsg);
mir_free(tMsg);
return result;
}
@@ -149,31 +149,32 @@ TCHAR *GetDefaultStatusMessage(PROTOCOLSETTINGEX *ps, int newstatus) return NULL;
}
-static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) {
+static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps)
+{
int i, j, pstatus = 0, gstatus = 0;
- for ( i=0; i < protoList->getCount(); i++ )
- if ( ps[i]->szMsg != NULL && GetActualStatus(ps[i]) != ID_STATUS_OFFLINE )
+ for (i = 0; i < protoList->getCount(); i++)
+ if (ps[i]->szMsg != NULL && GetActualStatus(ps[i]) != ID_STATUS_OFFLINE)
return 0;
int count;
PROTOACCOUNT **protos;
ProtoEnumAccounts(&count, &protos);
- for (i=0; i < count; i++) {
- if ( !IsSuitableProto(protos[i]))
+ for (i = 0; i < count; i++) {
+ if (!IsSuitableProto(protos[i]))
continue;
pstatus = 0;
- for ( j=0; j < protoList->getCount(); j++ )
+ for (j = 0; j < protoList->getCount(); j++)
if (!strcmp(protos[i]->szModuleName, ps[j]->szName))
pstatus = GetActualStatus(ps[j]);
if (pstatus == 0)
pstatus = CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0);
- if ( db_get_b(NULL, protos[i]->szModuleName, "LockMainStatus", 0)) {
+ if (db_get_b(NULL, protos[i]->szModuleName, "LockMainStatus", 0)) {
// if proto is locked, pstatus must be the current status
if (pstatus != CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0))
return 0;
@@ -192,63 +193,60 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) { static void SetStatusMsg(PROTOCOLSETTINGEX *ps, int newstatus)
{
- TCHAR* tszMsg = GetDefaultStatusMessage( ps, newstatus );
- if ( tszMsg ) {
- /* replace the default vars in msg (I believe this is from core) */
- for ( int j=0; tszMsg[j]; j++ ) {
- TCHAR substituteStr[128];
-
- if ( tszMsg[j] != '%' )
+ TCHAR* tszMsg = GetDefaultStatusMessage(ps, newstatus);
+ if (tszMsg) {
+ /* replace the default vars in msg (I believe this is from core) */
+ for (int j = 0; tszMsg[j]; j++) {
+ if (tszMsg[j] != '%')
continue;
- if ( !_tcsnicmp( tszMsg+j, _T("%time%"), 6 ))
- GetTimeFormat( LOCALE_USER_DEFAULT, TIME_NOSECONDS, 0, 0, substituteStr, SIZEOF(substituteStr));
- else if ( !_tcsnicmp( tszMsg+j, _T("%date%"), 6 ))
- GetDateFormat( LOCALE_USER_DEFAULT, DATE_SHORTDATE, 0, 0, substituteStr, SIZEOF(substituteStr));
+ TCHAR substituteStr[128];
+ if (!_tcsnicmp(tszMsg + j, _T("%time%"), 6))
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, 0, 0, substituteStr, SIZEOF(substituteStr));
+ else if (!_tcsnicmp(tszMsg + j, _T("%date%"), 6))
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, 0, 0, substituteStr, SIZEOF(substituteStr));
else
continue;
- if ( lstrlen( substituteStr ) > 6 )
- tszMsg = (TCHAR*)mir_realloc(tszMsg, sizeof(TCHAR)*(lstrlen(tszMsg)+1+lstrlen(substituteStr)-6));
- MoveMemory( tszMsg + j + lstrlen(substituteStr), tszMsg+j+6, sizeof(TCHAR)*(lstrlen(tszMsg)-j-5));
- CopyMemory( tszMsg + j, substituteStr, sizeof(TCHAR)*lstrlen( substituteStr ));
+ if (lstrlen(substituteStr) > 6)
+ tszMsg = (TCHAR*)mir_realloc(tszMsg, sizeof(TCHAR)*(lstrlen(tszMsg) + 1 + lstrlen(substituteStr) - 6));
+ MoveMemory(tszMsg + j + lstrlen(substituteStr), tszMsg + j + 6, sizeof(TCHAR)*(lstrlen(tszMsg) - j - 5));
+ CopyMemory(tszMsg + j, substituteStr, sizeof(TCHAR)*lstrlen(substituteStr));
}
- TCHAR* szFormattedMsg = variables_parsedup(tszMsg, ps->tszAccName, NULL);
+ TCHAR *szFormattedMsg = variables_parsedup(tszMsg, ps->tszAccName, NULL);
if (szFormattedMsg != NULL) {
mir_free(tszMsg);
tszMsg = szFormattedMsg;
}
}
log_debugA("CommonStatus sets status message for %s directly", ps->szName);
- if ( CALLSERVICE_NOTFOUND == CallProtoService(ps->szName, PS_SETAWAYMSGT, newstatus, (LPARAM)tszMsg )) {
- char* sMsg = mir_t2a( tszMsg );
- CallProtoService(ps->szName, PS_SETAWAYMSG, newstatus, (LPARAM)sMsg );
- mir_free( sMsg );
+ if (CALLSERVICE_NOTFOUND == CallProtoService(ps->szName, PS_SETAWAYMSGT, newstatus, (LPARAM)tszMsg)) {
+ char* sMsg = mir_t2a(tszMsg);
+ CallProtoService(ps->szName, PS_SETAWAYMSG, newstatus, (LPARAM)sMsg);
+ mir_free(sMsg);
}
- mir_free( tszMsg );
+ mir_free(tszMsg);
}
INT_PTR SetStatusEx(WPARAM wParam, LPARAM lParam)
{
PROTOCOLSETTINGEX** protoSettings = *(PROTOCOLSETTINGEX***)wParam;
- if ( protoSettings == NULL )
+ if (protoSettings == NULL)
return -1;
- int globStatus = equalsGlobalStatus( protoSettings );
+ int globStatus = equalsGlobalStatus(protoSettings);
- /*
- issue with setting global status;
- things get messy because SRAway hooks ME_CLIST_STATUSMODECHANGE, so the status messages of SRAway and
- commonstatus will clash
- */
+ // issue with setting global status;
+ // things get messy because SRAway hooks ME_CLIST_STATUSMODECHANGE, so the status messages of SRAway and
+ // commonstatus will clash
NotifyEventHooks(hCSStatusChangedExEvent, (WPARAM)&protoSettings, 0);
// set all status messages first
- for (int i=0; i < protoList->getCount(); i++) {
- char* szProto = protoSettings[i]->szName;
- if ( !CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)szProto)) {
- log_debugA( "CommonStatus: %s is not loaded", szProto );
+ for (int i = 0; i < protoList->getCount(); i++) {
+ char *szProto = protoSettings[i]->szName;
+ if (!CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)szProto)) {
+ log_debugA("CommonStatus: %s is not loaded", szProto);
continue;
}
// some checks
@@ -266,10 +264,10 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM lParam) }
// status checks
- long protoFlag = Proto_Status2Flag( newstatus );
+ long protoFlag = Proto_Status2Flag(newstatus);
int b_Caps2 = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0) & protoFlag;
int b_Caps5 = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_5, 0) & protoFlag;
- if (newstatus != ID_STATUS_OFFLINE && ( !b_Caps2 || b_Caps5)) {
+ if (newstatus != ID_STATUS_OFFLINE && (!b_Caps2 || b_Caps5)) {
// status and status message for this status not supported
//log_debug("CommonStatus: status not supported %s", szProto);
continue;
@@ -285,17 +283,17 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM lParam) // set status message first
if (b_Caps1 && b_Caps3)
- SetStatusMsg( protoSettings[i], newstatus );
+ SetStatusMsg(protoSettings[i], newstatus);
// set the status
- if (newstatus != oldstatus) {
+ if (newstatus != oldstatus && !(b_Caps1 && b_Caps3 && ServiceExists(MS_NAS_SETSTATE))) {
log_debugA("CommonStatus sets status for %s to %d", szProto, newstatus);
CallProtoService(szProto, PS_SETSTATUS, (WPARAM)newstatus, 0);
}
}
- if ( globStatus != 0 ) {
- if ( !ServiceExists( MS_CLIST_SETSTATUSMODE )) {
+ if (globStatus != 0) {
+ if (!ServiceExists(MS_CLIST_SETSTATUSMODE)) {
log_debugA("CommonStatus: MS_CLIST_SETSTATUSMODE not available!");
return -1;
}
@@ -322,10 +320,10 @@ int GetProtoCount() int count;
PROTOACCOUNT **protos;
- ProtoEnumAccounts( &count, &protos );
+ ProtoEnumAccounts(&count, &protos);
- for (int i=0; i < count; i++)
- if ( IsSuitableProto(protos[i]))
+ for (int i = 0; i < count; i++)
+ if (IsSuitableProto(protos[i]))
pCount++;
return pCount;
@@ -353,7 +351,7 @@ static int onShutdown(WPARAM wParam, LPARAM lParam) int InitCommonStatus()
{
if (!CreateServices())
- HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown);
return 0;
}
diff --git a/plugins/StatusPlugins/commonstatus.h b/plugins/StatusPlugins/commonstatus.h index b04e095f21..3201653858 100644 --- a/plugins/StatusPlugins/commonstatus.h +++ b/plugins/StatusPlugins/commonstatus.h @@ -45,6 +45,7 @@ #include <m_netlib.h>
#include "m_statusplugins.h"
#include <m_utils.h>
+#include <m_NewAwaySys.h>
#include <win2k.h>
#if defined( _WIN64 )
|