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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
/*
oscaruserinfo.cpp - Oscar Protocol Plugin
Copyright (c) 2002 by Tom Linsky <[email protected]>
Kopete (c) 2002 by the Kopete developers <[email protected]>
*************************************************************************
* *
* This program is 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. *
* *
*************************************************************************
*/
#include "aimuserinfo.h"
#include "aimaccount.h"
#include "aimcontact.h"
#include "aimprotocol.h"
#include <tqlineedit.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqpushbutton.h>
#include <tqtimer.h>
#include <tdelocale.h>
#include <kstandarddirs.h>
#include <ktextbrowser.h>
#include <kdebug.h>
#include <tdeapplication.h>
#include <ktextedit.h>
#include <krun.h>
AIMUserInfoDialog::AIMUserInfoDialog( Kopete::Contact *c, AIMAccount *acc, bool modal,
TQWidget *parent, const char* name )
: KDialogBase( parent, name, modal, i18n( "User Information on %1" )
.arg( c->property( Kopete::Global::Properties::self()->nickName() ).value().toString() ),
Cancel | Ok , Ok, true )
{
kdDebug(14200) << k_funcinfo << "for contact '" << c->contactId() << "'" << endl;
m_contact = c;
mAccount = acc;
mMainWidget = new AIMUserInfoWidget(this, "aimuserinfowidget");
setMainWidget(mMainWidget);
TQObject::connect(this, TQ_SIGNAL(okClicked()), this, TQ_SLOT(slotSaveClicked()));
TQObject::connect(this, TQ_SIGNAL(user1Clicked()), this, TQ_SLOT(slotUpdateClicked()));
TQObject::connect(this, TQ_SIGNAL(cancelClicked()), this, TQ_SLOT(slotCloseClicked()));
TQObject::connect(c, TQ_SIGNAL(updatedProfile()), this, TQ_SLOT(slotUpdateProfile()));
mMainWidget->txtScreenName->setText( c->contactId() );
TQString nickName = c->property( Kopete::Global::Properties::self()->nickName() ).value().toString();
if( nickName.isEmpty() )
mMainWidget->txtNickName->setText( c->contactId() );
else
mMainWidget->txtNickName->setText( nickName );
if(m_contact == mAccount->myself()) // edit own account profile
{
mMainWidget->lblWarnLevel->hide();
mMainWidget->txtWarnLevel->hide();
mMainWidget->lblIdleTime->hide();
mMainWidget->txtIdleTime->hide();
mMainWidget->lblOnlineSince->hide();
mMainWidget->txtOnlineSince->hide();
mMainWidget->txtAwayMessage->hide();
mMainWidget->lblAwayMessage->hide();
userInfoView=0L;
mMainWidget->userInfoFrame->setFrameStyle(TQFrame::NoFrame | TQFrame::Plain);
TQVBoxLayout *l = new TQVBoxLayout(mMainWidget->userInfoFrame);
userInfoEdit = new KTextEdit(TQString(), TQString(),
mMainWidget->userInfoFrame, "userInfoEdit");
userInfoEdit->setTextFormat(PlainText);
AIMMyselfContact* aimmc = dynamic_cast<AIMMyselfContact*>( c );
if ( aimmc )
userInfoEdit->setText( aimmc->userProfile() );
else
userInfoEdit->setText( TQString() );
setButtonText(Ok, i18n("&Save Profile"));
showButton(User1, false);
l->addWidget(userInfoEdit);
}
else
{
userInfoEdit=0L;
mMainWidget->userInfoFrame->setFrameStyle(TQFrame::NoFrame | TQFrame::Plain);
TQVBoxLayout *l = new TQVBoxLayout(mMainWidget->userInfoFrame);
userInfoView = new KTextBrowser(mMainWidget->userInfoFrame, "userInfoView");
userInfoView->setTextFormat(AutoText);
userInfoView->setNotifyClick(true);
TQObject::connect(
userInfoView, TQ_SIGNAL(urlClick(const TQString&)),
this, TQ_SLOT(slotUrlClicked(const TQString&)));
TQObject::connect(
userInfoView, TQ_SIGNAL(mailClick(const TQString&, const TQString&)),
this, TQ_SLOT(slotMailClicked(const TQString&, const TQString&)));
showButton(Cancel, false);
setButtonText(Ok, i18n("&Close"));
setEscapeButton(Ok);
l->addWidget(userInfoView);
if(m_contact->isOnline())
{
// Update the user view to indicate that we're requesting the user's profile
userInfoView->setText(i18n("Requesting User Profile, please wait..."));
}
TQTimer::singleShot(0, this, TQ_SLOT(slotUpdateProfile()));
}
}
AIMUserInfoDialog::~AIMUserInfoDialog()
{
kdDebug(14200) << k_funcinfo << "Called." << endl;
}
void AIMUserInfoDialog::slotUpdateClicked()
{
kdDebug(14200) << k_funcinfo << "Called." << endl;
TQString newNick = mMainWidget->txtNickName->text();
TQString currentNick = m_contact->property( Kopete::Global::Properties::self()->nickName() ).value().toString();
if ( !newNick.isEmpty() && ( newNick != currentNick ) )
{
//m_contact->rename(newNick);
//emit updateNickname(newNick);
setCaption(i18n("User Information on %1").arg(newNick));
}
}
void AIMUserInfoDialog::slotSaveClicked()
{
kdDebug(14200) << k_funcinfo << "Called." << endl;
if (userInfoEdit)
{ // editable mode, set profile
TQString newNick = mMainWidget->txtNickName->text();
TQString currentNick = m_contact->property( Kopete::Global::Properties::self()->nickName() ).value().toString();
if(!newNick.isEmpty() && ( newNick != currentNick ) )
{
//m_contact->rename(newNick);
//emit updateNickname(newNick);
setCaption(i18n("User Information on %1").arg(newNick));
}
mAccount->setUserProfile(userInfoEdit->text());
}
emit closing();
}
void AIMUserInfoDialog::slotCloseClicked()
{
kdDebug(14200) << k_funcinfo << "Called." << endl;
emit closing();
}
void AIMUserInfoDialog::slotUpdateProfile()
{
kdDebug(14152) << k_funcinfo << "Got User Profile." << endl;
AIMProtocol* p = static_cast<AIMProtocol*>( mAccount->protocol() );
TQString awayMessage = m_contact->property( p->awayMessage ).value().toString();
mMainWidget->txtAwayMessage->setText( awayMessage );
if ( awayMessage.isNull() )
{
mMainWidget->txtAwayMessage->hide();
mMainWidget->lblAwayMessage->hide();
}
else
{
mMainWidget->txtAwayMessage->show();
mMainWidget->lblAwayMessage->show();
}
TQString onlineSince = m_contact->property("onlineSince").value().toString();
//TQString onlineSince = m_details.onlineSinceTime().toString();
mMainWidget->txtOnlineSince->setText( onlineSince );
AIMContact* c = static_cast<AIMContact*>( m_contact );
mMainWidget->txtIdleTime->setText(c->formattedIdleTime());
mMainWidget->txtWarnLevel->setText(TQString::number(c->warningLevel()));
TQString contactProfile = m_contact->property( p->clientProfile ).value().toString();
if ( contactProfile.isNull() )
{
contactProfile =
i18n("<html><body><I>No user information provided</I></body></html>");
}
if(userInfoEdit)
{
userInfoEdit->setText(contactProfile);
}
else if(userInfoView)
{
userInfoView->setText(contactProfile);
}
}
void AIMUserInfoDialog::slotUrlClicked(const TQString &url)
{
new KRun(KURL(url));
}
void AIMUserInfoDialog::slotMailClicked(const TQString&, const TQString &address)
{
new KRun(KURL(address));
}
#include "aimuserinfo.moc"
|