summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/oscar/liboscar/oscarutils.h
blob: 44a0a7f95364abc0726f4a5b2e338d03294af012 (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
/*
    Kopete Oscar Protocol
    oscarutils.h - Oscar Utility Functions

    Copyright (c) 2004 Matt Rogers <[email protected]>

    Kopete (c) 2002-2004 by the Kopete developers <[email protected]>

    *************************************************************************
    *                                                                       *
    * This library is free software; you can redistribute it and/or         *
    * modify it under the terms of the GNU Lesser General Public            *
    * License as published by the Free Software Foundation; either          *
    * version 2 of the License, or (at your option) any later version.      *
    *                                                                       *
    *************************************************************************
*/

#ifndef _OSCARUTILS_H_
#define _OSCARUTILS_H_

#include <tqglobal.h>
#include <tqvaluelist.h>
#include <tqstring.h>
#include "oscartypes.h"
#include "buffer.h"

namespace Oscar
{

///Normalize the contact name to all lowercase and no spaces
KOPETE_EXPORT TQString normalize( const TQString& );

///compare TLVs for equality
KOPETE_EXPORT bool operator==( TLV, TLV );

/**
 * Find the TLV corresponding to the type in the list
 */
KOPETE_EXPORT TLV findTLV( const TQValueList<TLV>&, int type );

/**
 * Update TLVs of SSI item from TLV list if necessary
 * \return true if something was updated
 */
KOPETE_EXPORT bool uptateTLVs( SSI& item, const TQValueList<TLV>& list );

/**
 * Get the value of the capability that corresponds to the value
 * in the Capabilities enum
 * \return -1 if the capability isn't found
 * \return a non-negative number corresponding to the value of the 
 * capability in the Capabilities enum
 */
int parseCap( char* cap );

/**
 * Convert the capability to a string we can print
 */
const TQString capToString(char *cap);

/**
 * Parse the character array for validness and a version string
 * \param buffer the buffer we'll be parsing for capabilities
 * \param versionString a TQString reference that will contain the
 * version string of the detected client. Will be TQString() if 
 * no client is found
 * \return a DWORD containg a bit array of the capabilities we found
 */
DWORD parseCapabilities(Buffer &inbuf, TQString &versionString);

/**
 * Get the name of the capability from its number
 */
const TQString capName( int capNumber );

/**
 * Convert an IP address in dotted decimal notation to a 
 * numerical constant
 */
DWORD getNumericalIP( const TQString& address );

/**
 * Convert a numerical constant that is an IP address to
 * dotted decimal format
 */
TQString getDottedDecimal( DWORD address );

}

#endif