aboutsummaryrefslogtreecommitdiffstats
path: root/doc/user-guide/help.xsl
blob: b7e3c3718483992b2c74f821bf38a8e7972a76fc (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
<?xml version='1.0'?>
<!--
	Convert DocBook documentation to help.txt file used by bitlbee
	(C) 2004 Jelmer Vernooij
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	version="1.1">

	<xsl:output method="text" encoding="utf-8" standalone="yes"/>
	<xsl:strip-space elements="*"/>

	<xsl:template match="text()">
		<xsl:if test="starts-with(.,' ') and preceding-sibling::* and
			not(preceding-sibling::*[1]/node()[1][self::text() and contains(concat(.,'^$%'),' ^$%')])">
			<xsl:text> </xsl:text>
		</xsl:if>
	
		<xsl:value-of select="normalize-space(.)"/>
		<xsl:if test="contains(concat(.,'^$%'),' ^$%') and following-sibling::* and
			not(following-sibling::*[1]/node()[1][self::text() and starts-with(.,' ')])">
			<xsl:text> </xsl:text>
		</xsl:if>
	</xsl:template>

	<xsl:template match="para">
		<xsl:apply-templates/><xsl:text>&#10;</xsl:text>
		<xsl:if test="$extraparanewline = '1'">
			<xsl:text>&#10;</xsl:text>
		</xsl:if>
	</xsl:template>

	<xsl:template name="subject">
		<xsl:param name="id"/>
		<xsl:message><xsl:text>Processing: </xsl:text><xsl:value-of select="$id"/></xsl:message>
		<xsl:text>?</xsl:text><xsl:value-of select="$id"/><xsl:text>&#10;</xsl:text>

		<xsl:for-each select="para|variablelist|simplelist|command-list|ircexample">
			<xsl:if test="title != ''">
				<xsl:value-of select="title"/><xsl:text>&#10;</xsl:text>
			</xsl:if>
			<xsl:apply-templates select="."/>
		</xsl:for-each>
		<xsl:text>%&#10;</xsl:text>

		<xsl:for-each select="sect1|sect2">
			<xsl:call-template name="subject">
				<xsl:with-param name="id" select="@id"/>
			</xsl:call-template>
		</xsl:for-each>

		<xsl:for-each select="bitlbee-command">
			<xsl:call-template name="cmd">
				<xsl:with-param name="prefix" select="''"/>
			</xsl:call-template>
		</xsl:for-each>

		<xsl:for-each select="bitlbee-setting">
			<xsl:message><xsl:text>Processing setting '</xsl:text><xsl:value-of select="@name"/><xsl:text>'</xsl:text></xsl:message>
			<xsl:text>?set </xsl:text><xsl:value-of select="@name"/><xsl:text>&#10;</xsl:text>
			<xsl:text>_b_Type:_b_ </xsl:text><xsl:value-of select="@type"/><xsl:text>&#10;</xsl:text>
			<xsl:text>_b_Scope:_b_ </xsl:text><xsl:value-of select="@scope"/><xsl:text>&#10;</xsl:text>
			<xsl:if test="default">
				<xsl:text>_b_Default:_b_ </xsl:text><xsl:value-of select="default"/><xsl:text>&#10;</xsl:text>
			</xsl:if>
			<xsl:if test="possible-values">
				<xsl:text>_b_Possible Values:_b_ </xsl:text><xsl:value-of select="possible-values"/><xsl:text>&#10;</xsl:text>
			</xsl:if>
			<xsl:text>&#10;</xsl:text>
			<xsl:apply-templates select="description"/>
			<xsl:text>%&#10;</xsl:text>
		</xsl:for-each>
	</xsl:template>

	<xsl:template match="command-list">
		<xsl:for-each select="../bitlbee-command">
			<xsl:text> * _b_</xsl:text><xsl:value-of select="@name"/><xsl:text>_b_ - </xsl:text><xsl:value-of select="short-description"/><xsl:text>&#10;</xsl:text>
		</xsl:for-each>
		<xsl:text>&#10;</xsl:text>
	</xsl:template>

	<xsl:template match="preface|chapter|sect1|sect2">
		<xsl:call-template name="subject">
			<xsl:with-param name="id" select="@id"/>
		</xsl:call-template>
	</xsl:template>

	<xsl:template match="emphasis">
		<xsl:text>_b_</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>_b_</xsl:text>
	</xsl:template>

	<xsl:template match="book">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="variablelist">
		<xsl:for-each select="varlistentry">
			<xsl:text> _b_</xsl:text><xsl:value-of select="term"/><xsl:text>_b_ - </xsl:text><xsl:value-of select="listitem/para"/><xsl:text>&#10;</xsl:text>
		</xsl:for-each>
		<xsl:text>&#10;</xsl:text>
	</xsl:template>

	<xsl:template match="simplelist">
		<xsl:for-each select="member">
			<xsl:text> - </xsl:text><xsl:apply-templates/><xsl:text>&#10;</xsl:text>
		</xsl:for-each>
		<xsl:text>&#10;</xsl:text>
	</xsl:template>

	<xsl:template match="ircline">
		<xsl:text>_b_&lt;</xsl:text><xsl:value-of select="@nick"/><xsl:text>&gt;_b_ </xsl:text><xsl:value-of select="."/><xsl:text>&#10;</xsl:text>
	</xsl:template>

	<xsl:template match="ircaction">
		<xsl:text>_b_* </xsl:text><xsl:value-of select="@nick"/><xsl:text>_b_ </xsl:text><xsl:value-of select="."/><xsl:text>&#10;</xsl:text>
	</xsl:template>

	<xsl:template match="ircexample">
		<xsl:apply-templates/>
		<xsl:text>&#10;</xsl:text>
	</xsl:template>

	<xsl:template name="cmd">
		<xsl:param name="prefix"/>
		<xsl:variable name="thiscmd"><xsl:value-of select="$prefix"/><xsl:value-of select="@name"/></xsl:variable>
		<xsl:message><xsl:text>Processing command '</xsl:text><xsl:value-of select="$thiscmd"/><xsl:text>'</xsl:text></xsl:message>
		<xsl:text>?</xsl:text><xsl:value-of select="$thiscmd"/><xsl:text>&#10;</xsl:text>
		<xsl:for-each select="syntax">
			<xsl:text>_b_Syntax:_b_ </xsl:text><xsl:value-of select="."/><xsl:text>&#10;</xsl:text>
		</xsl:for-each>
		<xsl:text>&#10;</xsl:text>

		<xsl:apply-templates select="description"/>

		<xsl:for-each select="ircexample">
			<xsl:text>_b_Example:_b_&#10;</xsl:text>
			<xsl:apply-templates select="."/>
		</xsl:for-each>

		<!--
		<xsl:if test="bitlbee-command != ''">
			<xsl:text>Subcommands: </xsl:text>
			<xsl:for-each select="bitlbee-command">
				<xsl:value-of select="@name"/><xsl:text>, </xsl:text>
			</xsl:for-each>
			<xsl:text>&#10;</xsl:text>
		</xsl:if>
		-->

		<xsl:text>%&#10;</xsl:text>

		<xsl:for-each select="bitlbee-command">
			<xsl:call-template name="cmd">
				<xsl:with-param name="prefix"><xsl:value-of select="$thiscmd"/><xsl:text> </xsl:text></xsl:with-param>
			</xsl:call-template>
		</xsl:for-each>

	</xsl:template>

</xsl:stylesheet>
>return g_strdup( set->def ); } } else if( strcmp( set->key, "username" ) == 0 ) { g_free( acc->user ); acc->user = g_strdup( value ); return value; } else if( strcmp( set->key, "password" ) == 0 ) { if( value ) { g_free( acc->pass ); acc->pass = g_strdup( value ); return NULL; /* password shouldn't be visible in plaintext! */ } else { /* NULL can (should) be stored in the set_t variable, but is otherwise not correct. */ return SET_INVALID; } } else if( strcmp( set->key, "auto_connect" ) == 0 ) { if( !is_bool( value ) ) return SET_INVALID; acc->auto_connect = bool2int( value ); return value; } else if( strcmp( set->key, "away" ) == 0 || strcmp( set->key, "status" ) == 0 ) { if( acc->ic && acc->ic->flags & OPT_LOGGED_IN ) { /* If we're currently on-line, set the var now already (bit of a hack) and send an update. */ g_free( set->value ); set->value = g_strdup( value ); imc_away_send_update( acc->ic ); } return value; } return SET_INVALID; } account_t *account_get( bee_t *bee, char *id ) { account_t *a, *ret = NULL; char *handle, *s; int nr; /* This checks if the id string ends with (...) */ if( ( handle = strchr( id, '(' ) ) && ( s = strchr( handle, ')' ) ) && s[1] == 0 ) { struct prpl *proto; *s = *handle = 0; handle ++; if( ( proto = find_protocol( id ) ) ) { for( a = bee->accounts; a; a = a->next ) if( a->prpl == proto && a->prpl->handle_cmp( handle, a->user ) == 0 ) ret = a; } /* Restore the string. */ handle --; *handle = '('; *s = ')'; if( ret ) return ret; } if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 ) { for( a = bee->accounts; a; a = a->next ) if( ( nr-- ) == 0 ) return( a ); return( NULL ); } for( a = bee->accounts; a; a = a->next ) { if( g_strcasecmp( id, a->prpl->name ) == 0 ) { if( !ret ) ret = a; else return( NULL ); /* We don't want to match more than one... */ } else if( strstr( a->user, id ) ) { if( !ret ) ret = a; else return( NULL ); } } return( ret ); } void account_del( bee_t *bee, account_t *acc ) { account_t *a, *l = NULL; if( acc->ic ) /* Caller should have checked, accounts still in use can't be deleted. */ return; for( a = bee->accounts; a; a = (l=a)->next ) if( a == acc ) { if( l ) l->next = a->next; else bee->accounts = a->next; /** FIXME for( c = bee->chatrooms; c; c = nc ) { nc = c->next; if( acc == c->acc ) chat_del( bee, c ); } */ while( a->set ) set_del( &a->set, a->set->key ); g_hash_table_destroy( a->nicks ); g_free( a->user ); g_free( a->pass ); g_free( a->server ); if( a->reconnect ) /* This prevents any reconnect still queued to happen */ cancel_auto_reconnect( a ); g_free( a ); break; } } void account_on( bee_t *bee, account_t *a ) { if( a->ic ) { /* Trying to enable an already-enabled account */ return; } cancel_auto_reconnect( a ); a->reconnect = 0; a->prpl->login( a ); } void account_off( bee_t *bee, account_t *a ) { imc_logout( a->ic, FALSE ); a->ic = NULL; if( a->reconnect ) { /* Shouldn't happen */ cancel_auto_reconnect( a ); } } struct account_reconnect_delay { int start; char op; int step; int max; }; int account_reconnect_delay_parse( char *value, struct account_reconnect_delay *p ) { memset( p, 0, sizeof( *p ) ); /* A whole day seems like a sane "maximum maximum". */ p->max = 86400; /* Format: /[0-9]+([*+][0-9]+(<[0-9+])?)?/ */ while( *value && isdigit( *value ) ) p->start = p->start * 10 + *value++ - '0'; /* Sure, call me evil for implementing my own fscanf here, but it's dead simple and I immediately know where to continue parsing. */ if( *value == 0 ) /* If the string ends now, the delay is constant. */ return 1; else if( *value != '+' && *value != '*' ) /* Otherwise allow either a + or a * */ return 0; p->op = *value++; /* + or * the delay by this number every time. */ while( *value && isdigit( *value ) ) p->step = p->step * 10 + *value++ - '0'; if( *value == 0 ) /* Use the default maximum (one day). */ return 1; else if( *value != '<' ) return 0; p->max = 0; value ++; while( *value && isdigit( *value ) ) p->max = p->max * 10 + *value++ - '0'; return p->max > 0; } char *set_eval_account_reconnect_delay( set_t *set, char *value ) { struct account_reconnect_delay p; return account_reconnect_delay_parse( value, &p ) ? value : SET_INVALID; } int account_reconnect_delay( account_t *a ) { char *setting = set_getstr( &a->bee->set, "auto_reconnect_delay" ); struct account_reconnect_delay p; if( account_reconnect_delay_parse( setting, &p ) ) { if( a->auto_reconnect_delay == 0 ) a->auto_reconnect_delay = p.start; else if( p.op == '+' ) a->auto_reconnect_delay += p.step; else if( p.op == '*' ) a->auto_reconnect_delay *= p.step; if( a->auto_reconnect_delay > p.max ) a->auto_reconnect_delay = p.max; } else { a->auto_reconnect_delay = 0; } return a->auto_reconnect_delay; }