~ubuntu-branches/ubuntu/hoary/psi/hoary

« back to all changes in this revision

Viewing changes to src/info.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2004-06-15 00:10:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040615001041-enywb6pcpe4sjsw6
Tags: 0.9.2-1
* New upstream release
* Set KDEDIR for ./configure so kde specific files get installed
* Don't install libpsiwidgets.so. It got installed in /usr/share
  where it doesn't belong. May be included (at a better location)
  later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
** info.cpp - manage contact information
3
 
** Copyright (C) 2001, 2002  Justin Karneges
4
 
**
5
 
** This program is free software; you can redistribute it and/or
6
 
** modify it under the terms of the GNU General Public License
7
 
** as published by the Free Software Foundation; either version 2
8
 
** of the License, or (at your option) any later version.
9
 
**
10
 
** This program is distributed in the hope that it will be useful,
11
 
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
** GNU General Public License for more details.
14
 
**
15
 
** You should have received a copy of the GNU General Public License
16
 
** along with this program; if not, write to the Free Software
17
 
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 
**
19
 
****************************************************************************/
20
 
 
21
 
#include"info.h"
22
 
#include"common.h"
23
 
 
24
 
#include<qdom.h>
25
 
#include<qfile.h>
26
 
 
27
 
InfoBank IB;
28
 
 
29
 
 
30
 
InfoBank::InfoBank()
31
 
{
32
 
        list.setAutoDelete(TRUE);
33
 
}
34
 
 
35
 
void InfoBank::put_item(Info *p)
36
 
{
37
 
        Info *old = get_item(p->jid);
38
 
        if(old)
39
 
                list.remove(old);
40
 
 
41
 
        list.append(p);
42
 
}
43
 
 
44
 
Info *InfoBank::get_item(const QString &)
45
 
{
46
 
        return 0;
47
 
 
48
 
        /*for(Info *p = list.start(); p; p = list.next()) {
49
 
                if(jidcmp(p->jid, jid))
50
 
                        return p;
51
 
        }
52
 
 
53
 
        return 0;*/
54
 
}
55
 
 
56
 
/* static */ void InfoBank::put(Info *p)
57
 
{
58
 
        IB.put_item(p);
59
 
}
60
 
 
61
 
/* static */ Info *InfoBank::get(const QString &jid)
62
 
{
63
 
        return IB.get_item(jid);
64
 
}
65
 
 
66
 
/*bool InfoBank::readUserInfo(const QString &jid, VCard *info)
67
 
{
68
 
        QFile f;
69
 
        QString str = cleanJid(jid);
70
 
        QString fname = path_home + "/" + qstrlower(jidEncode(str)) + ".info";
71
 
        pdb(DEBUG_JABCON, QString("UserInfo: fname=[%1]\n").arg(fname.latin1()));
72
 
        f.setName(fname);
73
 
        if(!f.open(IO_ReadOnly))
74
 
                return FALSE;
75
 
 
76
 
        QDomDocument doc("info");
77
 
        if(!doc.setContent(&f)) {
78
 
                f.close();
79
 
                return FALSE;
80
 
        }
81
 
        f.close();
82
 
 
83
 
        QDomElement docElem = doc.documentElement();
84
 
        if(!info->fromXml(docElem))
85
 
                return FALSE;
86
 
 
87
 
        info->jid = jid;
88
 
 
89
 
        return TRUE;
90
 
}
91
 
 
92
 
bool InfoBank::writeUserInfo(const QString &jid, const VCard &info)
93
 
{
94
 
        QFile f;
95
 
        QString str = cleanJid(jid);
96
 
        QString fname = path_home + "/" + qstrlower(jidEncode(str)) + ".info";
97
 
        pdb(DEBUG_JABCON, QString("UserInfo: fname=[%1]\n").arg(fname.latin1()));
98
 
        f.setName(fname);
99
 
        if(!f.open(IO_WriteOnly))
100
 
                return FALSE;
101
 
        QTextStream t;
102
 
        t.setDevice(&f);
103
 
        info.xml.save(t, 0);
104
 
        t.unsetDevice();
105
 
        f.close();
106
 
 
107
 
        return TRUE;
108
 
}
109
 
*/