~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp

  • Committer: Package Import Robot
  • Author(s): Kai Wasserbäch
  • Date: 2011-09-29 16:27:07 UTC
  • mfrom: (0.3.15 upstream)
  • Revision ID: package-import@ubuntu.com-20110929162707-t29s6itjnsg2syuf
Tags: 4:4.1.3+20110929.svn5980-1
The "Balance of Power" release.

* Synced to upstream's SVN revision 5980.
* debian/control:
  - Vcs-* fields updated.
  - Remove libcrypto++-dev from B-Ds, was dropped upstream.
  - Bumped B-D on debhelper to >= 8.9.4.
* debian/rules:
  - Remove a now obsolete flag.
  - Upstream fixed a typo in a configuration variable name (now
    WANT_COEXISTENCE), updated invocation.
* debian/compat: Now at 9.
* Make KVIrc multiarch ready:
  - debian/{kvirc,libkvilib4,kvirc-modules}.install: Split out binaries
    under /usr/lib.
  - debian/rules: Add -DLIB_SUFFIX to dh_auto_configure invocation.
  - debian/control:
    + Added new packages (needed for split).
    + Added Multi-Arch fields
    + Added Pre-Depends: multiarch-support and ${misc:Pre-Depends} where
      needed.
    + Bumped B-D on CMake.
  - debian/{kvirc,libkvilib4,kvirc-modules}.lintian-overrides: Moved and
    updated overrides to match new locations (one could be dropped in the
    process).

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "KviKvsEventManager.h"
41
41
#include "KviKvsEventHandler.h"
42
42
#include "KviLagMeter.h"
43
 
 
 
43
#include "KviIrcUserEntry.h"
44
44
#include <QRegExp>
45
45
 
46
46
namespace KviKvsCoreFunctions
47
47
{
 
48
 
 
49
/////////////////////////////////////////////////////////////////////////////////////////
 
50
 
 
51
/*
 
52
        @doc:   gender
 
53
        @type:
 
54
                function
 
55
        @title:
 
56
                $gender
 
57
        @short:
 
58
                Returns the gender of the specified user
 
59
        @syntax:
 
60
                <string> $gender(<nickname:string>)
 
61
        @description:
 
62
                Returns the gender, or 'unknown' if not setted from remote user, of the specified IRC user IF it is known.[br]
 
63
                The gender is known if [fnc]$isWellKnown[/fnc] returns 1.[br]
 
64
                The gender is generally known if the user is on a channel with you
 
65
                or has an open query with you.[br]
 
66
                Detailed explaination:[br]
 
67
                KVIrc has an internal database of users that are currently
 
68
                visible by *this client*: this includes users on open channels
 
69
                and queries.[br] The other IRC users are NOT in the database:
 
70
                this means that KVIrc knows NOTHING about them and can't return
 
71
                any information immediately. In this case this function will return
 
72
                an EMPTY string.[br]
 
73
                If a user is in the database, at least his nickname is known.[br]
 
74
                The username and hostname are known only if the server provides that information
 
75
                spontaneously or after a KVIrc request.[br]
 
76
                KVIrc requests user information for all the users in open queries
 
77
                and channels. This information takes some time to be retrieved,
 
78
                in this interval of time KVIrc knows only the user's nickname.
 
79
                This function will return the string "*" in this case.[br]
 
80
        @seealso:
 
81
                [fnc]$isWellKnown[/fnc], [fnc]$hostname[/fnc], [fnc]$realname[/fnc], [cmd]$username[/cmd]
 
82
*/
 
83
 
 
84
KVSCF(gender)
 
85
{
 
86
        QString szNick;
 
87
 
 
88
        KVSCF_PARAMETERS_BEGIN
 
89
                KVSCF_PARAMETER("nick",KVS_PT_NONEMPTYSTRING,0,szNick)
 
90
        KVSCF_PARAMETERS_END
 
91
 
 
92
        if(KVSCF_pContext->window()->console())
 
93
        {
 
94
                if(KVSCF_pContext->window()->console()->isConnected())
 
95
                {
 
96
                        KviIrcUserEntry * e = KVSCF_pContext->window()->connection()->userDataBase()->find(szNick);
 
97
                        if(e)
 
98
                        {
 
99
                                QString szGender;
 
100
                                if(e->gender()==KviIrcUserEntry::Male) szGender = "male";
 
101
                                else if(e->gender()==KviIrcUserEntry::Female) szGender = "female";
 
102
                                else szGender = "unknown";
 
103
                                KVSCF_pRetBuffer->setString(szGender);
 
104
                                return true;
 
105
                        }
 
106
                }
 
107
        }
 
108
 
 
109
        KVSCF_pRetBuffer->setNothing();
 
110
        return true;
 
111
}
48
112
        ///////////////////////////////////////////////////////////////////////////////////////////////
49
113
 
50
114
        /*
233
297
        @short:
234
298
                Returns the lag on the current server
235
299
        @syntax:
236
 
                <integer> lag
 
300
                <integer> $lag
237
301
        @description:
238
302
                This function returns the lag in the current server, in milliseconds.[br]
239
303
        */
267
331
                        <float> $hptimestamp
268
332
                @description:
269
333
                        Returns a high precision timestamp as a floaint point value.
270
 
                        The timestamp rappresent the number of seconds elapsed since
 
334
                        The timestamp represents the number of seconds elapsed since
271
335
                        a certain moment in the past. The number of seconds
272
336
                        contains a "high precision" fractional part. The "certain moment" definition
273
337
                        depends on the platform KVIrc is executed. This means that
274
 
                        this timestamp is totally useless to rappresent a time value
 
338
                        this timestamp is totally useless to represent a time value
275
339
                        but is useful to compute time intervals with sub-second precision.
276
340
                @examples:
277
341
                        [example]
445
509
                return true;
446
510
        }
447
511
 
 
512
        /////////////////////////////////////////////////////////////////////////////////////////
 
513
 
 
514
        /*
 
515
                @doc:   isbot
 
516
                @type:
 
517
                        function
 
518
                @title:
 
519
                        $isbot
 
520
                @short:
 
521
                        Returns 1 if the user is a bot. Otherwise return 0.
 
522
                @syntax:
 
523
                        <string> $isbot(<nickname:string>)
 
524
                @description:
 
525
                        Returns 1 if the user is a bot. Otherwise return 0.[br]
 
526
                        This info  is known if [fnc]$isWellKnown[/fnc] returns 1.[br]
 
527
                        This info is generally known if the user is on a channel with you
 
528
                        or has an open query with you.[br]
 
529
                        Detailed explaination:[br]
 
530
                        KVIrc has an internal database of users that are currently
 
531
                        visible by *this client*: this includes users on open channels
 
532
                        and queries.[br] The other IRC users are NOT in the database:
 
533
                        this means that KVIrc knows NOTHING about them and can't return
 
534
                        any information immediately. In this case this function will return
 
535
                        an EMPTY string.[br]
 
536
                        If a user is in the database, at least his nickname is known.[br]
 
537
                        The username and hostname are known only if the server provides that information
 
538
                        spontaneously or after a KVIrc request.[br]
 
539
                        KVIrc requests user information for all the users in open queries
 
540
                        and channels. This information takes some time to be retrieved,
 
541
                        in this interval of time KVIrc knows only the user's nickname.
 
542
                        This function will return the string "*" in this case.[br]
 
543
                @seealso:
 
544
                        [fnc]$isWellKnown[/fnc], [fnc]$hostname[/fnc], [fnc]$realname[/fnc], [cmd]$username[/cmd]
 
545
        */
 
546
 
 
547
        KVSCF(isBot)
 
548
        {
 
549
                QString szNick;
 
550
 
 
551
                KVSCF_PARAMETERS_BEGIN
 
552
                        KVSCF_PARAMETER("nick",KVS_PT_NONEMPTYSTRING,0,szNick)
 
553
                KVSCF_PARAMETERS_END
 
554
 
 
555
                if(KVSCF_pContext->window()->console())
 
556
                {
 
557
                        if(KVSCF_pContext->window()->console()->isConnected())
 
558
                        {
 
559
                                KviIrcUserEntry * e = KVSCF_pContext->window()->connection()->userDataBase()->find(szNick);
 
560
                                if(e)
 
561
                                {
 
562
                                        KVSCF_pRetBuffer->setBoolean(e->isBot());
 
563
                                        return true;
 
564
                                }
 
565
                        }
 
566
                }
 
567
                KVSCF_pRetBuffer->setNothing();
 
568
                return true;
 
569
        }
448
570
        ///////////////////////////////////////////////////////////////////////////////////////////////
449
571
 
450
572
        /*
484
606
                @syntax:
485
607
                        <boolean> $isMainWindowMinimized()
486
608
                @description:
487
 
                        Returns true if main KVirc window is minimized and false otherwise.
 
609
                        Returns true if main KVIrc window is minimized and false otherwise.
488
610
        */
489
611
 
490
612
        KVSCF(isMainWindowMinimized)
541
663
                @syntax:
542
664
                        <boolean> $isEventEnabled(<event_name:string>,<handler_name:string>)
543
665
                @description:
544
 
                        Returns 1 if the event handler enabled
 
666
                        Returns 1 if the event handler is enabled.
545
667
        */
546
668
 
547
669
        ///////////////////////////////////////////////////////////////////////////////////////////////
596
718
                @syntax:
597
719
                        <boolean> $isNumeric(<data:variant>)
598
720
                @short:
599
 
                        Finds whether a variable contains a rappresentation of a number
 
721
                        Finds whether a variable contains a representation of a number
600
722
                @description:
601
723
                        Returns 1 if the <data> is an integer or a real number, 0 otherwise.
602
724
        */
661
783
                @syntax:
662
784
                        <boolean> $istimer(<name:string>)
663
785
                @description:
664
 
                        Returns 1 if the timer named <name> is actually running, else 0
 
786
                        Returns 1 if the timer named <name> is actually running, 0 otherwise.
665
787
                @seealso:
666
788
                        [cmd]timer[/cmd], [cmd]killtimer[/cmd]
667
789
        */
821
943
                @syntax:
822
944
                        <string> $lang([<type:string>])
823
945
                @description:
824
 
                        Returns the short name of currently used language
 
946
                        Returns the short name of currently used language.[br]
825
947
                        Type <type> should be one of: [br]
826
 
                        "full"  - returns full locale name, such as ru_RU.UTF-8 (default)
827
 
                        "lang"  - return language name, such as "ru_RU"
828
 
                        "short" - returns only language group such as "ru"
 
948
                        "full"  - returns full locale name, such as ru_RU.UTF-8 (default).[br]
 
949
                        "lang"  - return language name, such as "ru_RU".[br]
 
950
                        "short" - returns only language group such as "ru".[br]
829
951
        */
830
952
 
831
953
        KVSCF(lang)
909
1031
                @syntax:
910
1032
                        <string> $lf
911
1033
                @description:
912
 
                        Returns a line feed character
 
1034
                        Returns a line feed character.
913
1035
                @seealso:
914
1036
                        [fnc]$cr[/fnc], [fnc]$ascii[/fnc], [fnc]$char[/fnc]
915
1037
        */
1010
1132
                QString szText, szFlags;
1011
1133
                KVSCF_PARAMETERS_BEGIN
1012
1134
                        KVSCF_PARAMETER("text",KVS_PT_STRING,KVS_PF_OPTIONAL,szText)
1013
 
                        KVSM_PARAMETER("flags",KVS_PT_STRING,KVS_PF_OPTIONAL,szFlags)
 
1135
                        KVSCF_PARAMETER("flags",KVS_PT_STRING,KVS_PF_OPTIONAL,szFlags)
1014
1136
                KVSCF_PARAMETERS_END
1015
1137
 
1016
1138
                bool bCaseSensitive = szFlags.indexOf('s',0,Qt::CaseInsensitive) != -1;