summaryrefslogtreecommitdiff
path: root/plugins/Variables/src/variables.h
blob: 2029c5d8486ef31e4e500f115d11da4ab6888451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
    Variables Plugin for Miranda-IM (www.miranda-im.org)
    Copyright 2003-2006 P. Boon

    This program is mir_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
*/

#include <tchar.h> 
#include <malloc.h>

#include <windows.h>
#include <commctrl.h>
#include "uxtheme.h"
#include <stdio.h>
#include <time.h>
#include "resource.h"
#ifndef WINE
#include <win2k.h>
#endif
#include <newpluginapi.h>
#include <m_system_cpp.h>
#include <m_langpack.h>
#include <m_database.h>
#include <m_protosvc.h>
#include <m_clist.h>
#include <m_contacts.h>
#include <m_awaymsg.h>
#include <m_options.h>
#include <m_utils.h>
#include <m_icolib.h>
#include "m_variables.h"

#define MODULENAME				"Variables"

#include "../helpers/gen_helpers.h"

#define SETTING_STARTUPTEXT		"StartupText"
#define SETTING_STRIPCRLF		"StripCRLF"
#define SETTING_STRIPWS			"StripWS"
#define SETTING_STRIPALL		"StripAll"
#define SETTING_PARSEATSTARTUP	"ParseAtStartup"
#define SETTING_SPLITTERPOS		"SplitterPos"
#define SETTING_SUBJECT			"LastSubject"

#define FIELD_CHAR			'%'
#define FUNC_CHAR			'?'
#define FUNC_ONCE_CHAR		'!'
#define DONTPARSE_CHAR		'`'
#define TRYPARSE_CHAR_OPEN	'['
#define TRYPARSE_CHAR_CLOSE	']'
#define COMMENT_STRING		"#"

// special tokens
#define SUBJECT				"subject"
#define EXTRATEXT			"extratext"

// options
#define IDT_PARSE			1
#define DM_SPLITTERMOVED     (WM_USER+15)

// Messages you can send to the help window:
#define VARM_PARSE          (WM_APP+11) // wParam=lParam=0
#define VARM_SETINPUTTEXT	(WM_APP+12)
#define VARM_GETINPUTTEXT	(WM_APP+13)
#define VARM_GETINPUTTEXTLENGTH	(WM_APP+14)
#define VARM_SETSUBJECT     (WM_APP+15)
#define VARM_GETSUBJECT     (WM_APP+16) // wParam=HANDLE hContact
#define VARM_SETEXTRATEXT   (WM_APP+17)
#define VARM_GETEXTRATEXT   (WM_APP+18)
#define VARM_GETEXTRATEXTLENGTH (WM_APP+19)
#define VARM_GETDIALOG		(WM_APP+20)

// if a different struct internally is used, we can use TOKENREGISTEREX
#define TOKENREGISTEREX TOKENREGISTER

// old struct
typedef struct {
	int cbSize;
	char *szFormat;
	char *szSource;
	HANDLE hContact;
	int pCount;  // number of succesful parses
	int eCount;	 // number of failures
} FORMATINFOV1;

struct ParseOptions {
	BOOL bStripEOL;
	BOOL bStripWS;
	BOOL bStripAll;
};

// variables.c
//TCHAR *getArguments(char *string, char ***aargv, int *aargc);
//int isValidTokenChar(char c);
TCHAR *formatString(FORMATINFO *fi);
int  setParseOptions(struct ParseOptions *po);
int  LoadVarModule();
int  UnloadVarModule();
// tokenregister.c
int  registerIntToken(TCHAR *szToken, TCHAR *(*parseFunction)(ARGUMENTSINFO *ai), int extraFlags, char* szHelpText);
INT_PTR registerToken(WPARAM wParam, LPARAM lParam);
int  deRegisterToken(TCHAR *var);
TOKENREGISTEREX *searchRegister(TCHAR *var, int type);
TCHAR *parseFromRegister(ARGUMENTSINFO *ai);
TOKENREGISTEREX *getTokenRegister(int i);
int  getTokenRegisterCount();
TOKENREGISTER *getTokenRegisterByIndex(int i);
void deRegisterTemporaryVariables();
int  initTokenRegister();
int  deinitTokenRegister();
// contact.c
BYTE getContactInfoType(TCHAR* type);
TCHAR* getContactInfoT(BYTE type, HANDLE hContact);
int  getContactFromString( CONTACTSINFO* );
int  initContactModule();
int  deinitContactModule();
// alias
int  registerAliasTokens();
void unregisterAliasTokens();
// system
int  registerSystemTokens();
// external
int  registerExternalTokens();
int  deInitExternal();
// miranda
int  registerMirandaTokens();
// str
int  registerStrTokens();
// variables
int  registerVariablesTokens();
void unregisterVariablesTokens();
int  clearVariableRegister();
// logic
int  registerLogicTokens();
// math
int  registerMathTokens();
// metacontacts
int registerMetaContactsTokens();
// options
int  OptionsInit(WPARAM wParam, LPARAM lParam);
// reg exp
int  registerRegExpTokens();
// inet
int  registerInetTokens();
// xml
int  registerXsltTokens();
// trigger
int  initTriggerModule();
// help
INT_PTR  showHelpService(WPARAM wParam, LPARAM lParam);
INT_PTR  showHelpExService(WPARAM wParam, LPARAM lParam);
INT_PTR  getSkinItemService(WPARAM wParam, LPARAM lParam);
int  iconsChanged(WPARAM wParam, LPARAM lParam);

int ttoi(TCHAR *string);
TCHAR *itot(int num);

extern DWORD g_mirandaVersion;