Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 93213 | Differences between
and this patch

Collapse All | Expand All

(-)kdenetwork-3.3.2/kopete/protocols/msn/Makefile.am (-1 / +2 lines)
Lines 12-18 Link Here
12
12
13
libkopete_msn_shared_la_SOURCES = msnprotocol.cpp msnaccount.cpp msnaddcontactpage.cpp msncontact.cpp \
13
libkopete_msn_shared_la_SOURCES = msnprotocol.cpp msnaccount.cpp msnaddcontactpage.cpp msncontact.cpp \
14
	msnsocket.cpp msnmessagemanager.cpp msndebugrawcmddlg.cpp \
14
	msnsocket.cpp msnmessagemanager.cpp msndebugrawcmddlg.cpp \
15
	msnnotifysocket.cpp msnswitchboardsocket.cpp msnfiletransfersocket.cpp msninvitation.cpp msnp2p.cpp sha1.cpp
15
	msnnotifysocket.cpp msnswitchboardsocket.cpp msnfiletransfersocket.cpp msninvitation.cpp msnp2p.cpp sha1.cpp \
16
	sslloginhandler.cpp
16
17
17
libkopete_msn_shared_la_LIBADD  = ./ui/libkopetemsnui.la ../../libkopete/libkopete.la $(LIB_KIO)
18
libkopete_msn_shared_la_LIBADD  = ./ui/libkopetemsnui.la ../../libkopete/libkopete.la $(LIB_KIO)
18
libkopete_msn_shared_la_LDFLAGS = -version-info 0:0:0 -no-undefined $(all_libraries)
19
libkopete_msn_shared_la_LDFLAGS = -version-info 0:0:0 -no-undefined $(all_libraries)
(-)kdenetwork-3.3.2/kopete/protocols/msn/Makefile.in (-7 / +17 lines)
Lines 74-80 Link Here
74
	msnaddcontactpage.lo msncontact.lo msnsocket.lo \
74
	msnaddcontactpage.lo msncontact.lo msnsocket.lo \
75
	msnmessagemanager.lo msndebugrawcmddlg.lo msnnotifysocket.lo \
75
	msnmessagemanager.lo msndebugrawcmddlg.lo msnnotifysocket.lo \
76
	msnswitchboardsocket.lo msnfiletransfersocket.lo \
76
	msnswitchboardsocket.lo msnfiletransfersocket.lo \
77
	msninvitation.lo msnp2p.lo sha1.lo
77
	msninvitation.lo msnp2p.lo sha1.lo sslloginhandler.lo
78
#>- libkopete_msn_shared_la_OBJECTS =  \
78
#>- libkopete_msn_shared_la_OBJECTS =  \
79
#>- 	$(am_libkopete_msn_shared_la_OBJECTS)
79
#>- 	$(am_libkopete_msn_shared_la_OBJECTS)
80
#>+ 8
80
#>+ 8
Lines 83-89 Link Here
83
	msnaddcontactpage.lo msncontact.lo msnsocket.lo \
83
	msnaddcontactpage.lo msncontact.lo msnsocket.lo \
84
	msnmessagemanager.lo msndebugrawcmddlg.lo msnnotifysocket.lo \
84
	msnmessagemanager.lo msndebugrawcmddlg.lo msnnotifysocket.lo \
85
	msnswitchboardsocket.lo msnfiletransfersocket.lo \
85
	msnswitchboardsocket.lo msnfiletransfersocket.lo \
86
	msninvitation.lo msnp2p.lo sha1.lo
86
	msninvitation.lo msnp2p.lo sha1.lo sslloginhandler.lo
87
@KDE_USE_FINAL_FALSE@libkopete_msn_shared_la_OBJECTS = $(libkopete_msn_shared_la_nofinal_OBJECTS)
87
@KDE_USE_FINAL_FALSE@libkopete_msn_shared_la_OBJECTS = $(libkopete_msn_shared_la_nofinal_OBJECTS)
88
@KDE_USE_FINAL_TRUE@libkopete_msn_shared_la_OBJECTS = $(libkopete_msn_shared_la_final_OBJECTS)
88
@KDE_USE_FINAL_TRUE@libkopete_msn_shared_la_OBJECTS = $(libkopete_msn_shared_la_final_OBJECTS)
89
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
89
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
Lines 440-446 Link Here
440
CLEANFILES = dummy.cpp
440
CLEANFILES = dummy.cpp
441
libkopete_msn_shared_la_SOURCES = msnprotocol.cpp msnaccount.cpp msnaddcontactpage.cpp msncontact.cpp \
441
libkopete_msn_shared_la_SOURCES = msnprotocol.cpp msnaccount.cpp msnaddcontactpage.cpp msncontact.cpp \
442
	msnsocket.cpp msnmessagemanager.cpp msndebugrawcmddlg.cpp \
442
	msnsocket.cpp msnmessagemanager.cpp msndebugrawcmddlg.cpp \
443
	msnnotifysocket.cpp msnswitchboardsocket.cpp msnfiletransfersocket.cpp msninvitation.cpp msnp2p.cpp sha1.cpp
443
	msnnotifysocket.cpp msnswitchboardsocket.cpp msnfiletransfersocket.cpp msninvitation.cpp msnp2p.cpp sha1.cpp sslloginhandler.cpp
444
444
445
libkopete_msn_shared_la_LIBADD = ./ui/libkopetemsnui.la ../../libkopete/libkopete.la $(LIB_KIO)
445
libkopete_msn_shared_la_LIBADD = ./ui/libkopetemsnui.la ../../libkopete/libkopete.la $(LIB_KIO)
446
#>- libkopete_msn_shared_la_LDFLAGS = -version-info 0:0:0 -no-undefined $(all_libraries)
446
#>- libkopete_msn_shared_la_LDFLAGS = -version-info 0:0:0 -no-undefined $(all_libraries)
Lines 588-593 Link Here
588
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msnsocket.Plo@am__quote@
588
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msnsocket.Plo@am__quote@
589
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msnswitchboardsocket.Plo@am__quote@
589
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msnswitchboardsocket.Plo@am__quote@
590
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Plo@am__quote@
590
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Plo@am__quote@
591
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sslloginhandler.Plo@am__quote@
591
592
592
.cpp.o:
593
.cpp.o:
593
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
594
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
Lines 1027-1032 Link Here
1027
#>+ 2
1028
#>+ 2
1028
mocs: msnaddcontactpage.moc
1029
mocs: msnaddcontactpage.moc
1029
1030
1031
#>+ 3
1032
sslloginhandler.moc: $(srcdir)/sslloginhandler.h
1033
	$(MOC) $(srcdir)/sslloginhandler.h -o sslloginhandler.moc
1034
1035
#>+ 2
1036
mocs: sslloginhandler.moc
1037
1030
#>+ 8
1038
#>+ 8
1031
libkopete_msn_shared.la.closure: $(libkopete_msn_shared_la_OBJECTS) $(libkopete_msn_shared_la_DEPENDENCIES)
1039
libkopete_msn_shared.la.closure: $(libkopete_msn_shared_la_OBJECTS) $(libkopete_msn_shared_la_DEPENDENCIES)
1032
	@echo "int main() {return 0;}" > libkopete_msn_shared_la_closure.cpp
1040
	@echo "int main() {return 0;}" > libkopete_msn_shared_la_closure.cpp
Lines 1038-1047 Link Here
1038
1046
1039
#>+ 3
1047
#>+ 3
1040
clean-metasources:
1048
clean-metasources:
1041
	-rm -f  msndebugrawcmddlg.moc msnmessagemanager.moc msnfiletransfersocket.moc msncontact.moc msnprotocol.moc msnaccount.moc msnsocket.moc msnnotifysocket.moc msnswitchboardsocket.moc msnp2p.moc msnaddcontactpage.moc
1049
	-rm -f  msndebugrawcmddlg.moc msnmessagemanager.moc msnfiletransfersocket.moc msncontact.moc msnprotocol.moc msnaccount.moc msnsocket.moc msnnotifysocket.moc msnswitchboardsocket.moc msnp2p.moc msnaddcontactpage.moc sslloginhandler.moc
1042
1050
1043
#>+ 2
1051
#>+ 2
1044
KDE_DIST=kopete_msn.desktop msncontact.h msnp2p.h msnmessagemanager.h msnchatui.rc Changelog msnsocket.h ReleaseNotes msndebugrawcmddlg.h msnaccount.h msnfiletransfersocket.h sha1.h msninvitation.h Makefile.in msnswitchboardsocket.h msnprotocol.h msnnotifysocket.h msnaddcontactpage.h Makefile.am 
1052
KDE_DIST=kopete_msn.desktop msncontact.h msnp2p.h msnmessagemanager.h sslloginhandler.h msnchatui.rc Changelog msnsocket.h ReleaseNotes msndebugrawcmddlg.h msnaccount.h msnfiletransfersocket.h sha1.h msninvitation.h Makefile.in msnswitchboardsocket.h msnprotocol.h msnnotifysocket.h msnaddcontactpage.h Makefile.am 
1045
1053
1046
#>+ 3
1054
#>+ 3
1047
clean-closures:
1055
clean-closures:
Lines 1089-1099 Link Here
1089
1097
1090
1098
1091
#>+ 11
1099
#>+ 11
1092
libkopete_msn_shared_la.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/msnprotocol.cpp $(srcdir)/msnaccount.cpp $(srcdir)/msnaddcontactpage.cpp $(srcdir)/msncontact.cpp $(srcdir)/msnsocket.cpp $(srcdir)/msnmessagemanager.cpp $(srcdir)/msndebugrawcmddlg.cpp $(srcdir)/msnnotifysocket.cpp $(srcdir)/msnswitchboardsocket.cpp $(srcdir)/msnfiletransfersocket.cpp $(srcdir)/msninvitation.cpp $(srcdir)/msnp2p.cpp $(srcdir)/sha1.cpp  msndebugrawcmddlg.moc msncontact.moc msnfiletransfersocket.moc msnmessagemanager.moc msnprotocol.moc msnaccount.moc msnsocket.moc msnnotifysocket.moc msnswitchboardsocket.moc msnp2p.moc msnaddcontactpage.moc
1100
libkopete_msn_shared_la.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/msnprotocol.cpp $(srcdir)/msnaccount.cpp $(srcdir)/msnaddcontactpage.cpp $(srcdir)/msncontact.cpp $(srcdir)/msnsocket.cpp $(srcdir)/msnmessagemanager.cpp $(srcdir)/msndebugrawcmddlg.cpp $(srcdir)/msnnotifysocket.cpp $(srcdir)/msnswitchboardsocket.cpp $(srcdir)/msnfiletransfersocket.cpp $(srcdir)/msninvitation.cpp $(srcdir)/msnp2p.cpp $(srcdir)/sslloginhandler.cpp $(srcdir)/sha1.cpp  msndebugrawcmddlg.moc msncontact.moc msnfiletransfersocket.moc msnmessagemanager.moc msnprotocol.moc msnaccount.moc msnsocket.moc msnnotifysocket.moc msnswitchboardsocket.moc msnp2p.moc msnaddcontactpage.moc sslloginhandler.moc
1093
	@echo 'creating libkopete_msn_shared_la.all_cpp.cpp ...'; \
1101
	@echo 'creating libkopete_msn_shared_la.all_cpp.cpp ...'; \
1094
	rm -f libkopete_msn_shared_la.all_cpp.files libkopete_msn_shared_la.all_cpp.final; \
1102
	rm -f libkopete_msn_shared_la.all_cpp.files libkopete_msn_shared_la.all_cpp.final; \
1095
	echo "#define KDE_USE_FINAL 1" >> libkopete_msn_shared_la.all_cpp.final; \
1103
	echo "#define KDE_USE_FINAL 1" >> libkopete_msn_shared_la.all_cpp.final; \
1096
	for file in msnprotocol.cpp msnaccount.cpp msnaddcontactpage.cpp msncontact.cpp msnsocket.cpp msnmessagemanager.cpp msndebugrawcmddlg.cpp msnnotifysocket.cpp msnswitchboardsocket.cpp msnfiletransfersocket.cpp msninvitation.cpp msnp2p.cpp sha1.cpp ; do \
1104
	for file in msnprotocol.cpp msnaccount.cpp msnaddcontactpage.cpp msncontact.cpp msnsocket.cpp msnmessagemanager.cpp msndebugrawcmddlg.cpp msnnotifysocket.cpp msnswitchboardsocket.cpp msnfiletransfersocket.cpp msninvitation.cpp msnp2p.cpp sha1.cpp sslloginhandler.cpp ; do \
1097
	  echo "#include \"$$file\"" >> libkopete_msn_shared_la.all_cpp.files; \
1105
	  echo "#include \"$$file\"" >> libkopete_msn_shared_la.all_cpp.files; \
1098
	  test ! -f $(srcdir)/$$file || egrep '^#pragma +implementation' $(srcdir)/$$file >> libkopete_msn_shared_la.all_cpp.final; \
1106
	  test ! -f $(srcdir)/$$file || egrep '^#pragma +implementation' $(srcdir)/$$file >> libkopete_msn_shared_la.all_cpp.final; \
1099
	done; \
1107
	done; \
Lines 1135-1140 Link Here
1135
msnaccount.lo: msnaccount.moc 
1143
msnaccount.lo: msnaccount.moc 
1136
msnaccount.o: msnaccount.moc 
1144
msnaccount.o: msnaccount.moc 
1137
msnp2p.lo: msnp2p.moc 
1145
msnp2p.lo: msnp2p.moc 
1146
sslloginhandler.lo: sslloginhandler.moc
1138
msnfiletransfersocket.o: msnfiletransfersocket.moc 
1147
msnfiletransfersocket.o: msnfiletransfersocket.moc 
1139
msnmessagemanager.lo: msnmessagemanager.moc 
1148
msnmessagemanager.lo: msnmessagemanager.moc 
1140
msndebugrawcmddlg.o: msndebugrawcmddlg.moc 
1149
msndebugrawcmddlg.o: msndebugrawcmddlg.moc 
Lines 1152-1155 Link Here
1152
msnswitchboardsocket.o: msnswitchboardsocket.moc 
1161
msnswitchboardsocket.o: msnswitchboardsocket.moc 
1153
msnaddcontactpage.lo: msnaddcontactpage.moc 
1162
msnaddcontactpage.lo: msnaddcontactpage.moc 
1154
msnp2p.o: msnp2p.moc 
1163
msnp2p.o: msnp2p.moc 
1164
sslloginhandler.o: sslloginhandler.moc
1155
msnfiletransfersocket.lo: msnfiletransfersocket.moc 
1165
msnfiletransfersocket.lo: msnfiletransfersocket.moc 
(-)kdenetwork-3.3.2/kopete/protocols/msn/msnnotifysocket.cpp (-89 / +24 lines)
Lines 23-28 Link Here
23
#include "msnnotifysocket.h"
23
#include "msnnotifysocket.h"
24
#include "msncontact.h"
24
#include "msncontact.h"
25
#include "msnaccount.h"
25
#include "msnaccount.h"
26
#include "sslloginhandler.h"
26
27
27
#include <qregexp.h>
28
#include <qregexp.h>
28
29
Lines 47-53 Link Here
47
: MSNSocket( account )
48
: MSNSocket( account )
48
{
49
{
49
	m_newstatus = MSNProtocol::protocol()->NLN;
50
	m_newstatus = MSNProtocol::protocol()->NLN;
50
	
51
	m_sslLoginHandler=0l;
52
51
	m_isHotmailAccount=false;
53
	m_isHotmailAccount=false;
52
	m_ping=false;
54
	m_ping=false;
53
55
Lines 66-72 Link Here
66
68
67
MSNNotifySocket::~MSNNotifySocket()
69
MSNNotifySocket::~MSNNotifySocket()
68
{
70
{
69
	delete m_tmpMailFile;
71
	delete m_sslLoginHandler;
70
	kdDebug(14140) << k_funcinfo << endl;
72
	kdDebug(14140) << k_funcinfo << endl;
71
}
73
}
72
74
Lines 246-252 Link Here
246
	
248
	
247
	if ( cmd == "VER" )
249
	if ( cmd == "VER" )
248
	{
250
	{
249
		sendCommand( "CVR", "0x0409 winnt 5.1 i386 MSNMSGR 6.0.0602 MSMSGS " + m_account->accountId() );
251
		sendCommand( "CVR", "0x0409 winnt 5.1 i386 MSNMSGR 6.2.0205 MSMSGS " + m_account->accountId() );
250
/*
252
/*
251
		struct utsname utsBuf;
253
		struct utsname utsBuf;
252
		uname ( &utsBuf );
254
		uname ( &utsBuf );
Lines 264-289 Link Here
264
	{
266
	{
265
		if( data.section( ' ', 1, 1 ) == "S" )
267
		if( data.section( ' ', 1, 1 ) == "S" )
266
		{
268
		{
267
			m_authData=data.section( ' ' , 2 , 2 );
269
			m_sslLoginHandler = new SslLoginHandler();
268
			m_kv=QString::null;
270
			QObject::connect( m_sslLoginHandler, SIGNAL(       loginFailed()        ),
271
					 this,            SLOT  (    sslLoginFailed()        ) );
272
			QObject::connect( m_sslLoginHandler, SIGNAL(    loginIncorrect()        ),
273
					 this,            SLOT  ( sslLoginIncorrect()        ) );
274
			QObject::connect( m_sslLoginHandler, SIGNAL(    loginSucceeded(QString) ),
275
					 this,            SLOT  ( sslLoginSucceeded(QString) ) );
269
276
270
			if( m_account->accountId().contains("@hotmail.com") )
277
			m_sslLoginHandler->login( data.section( ' ' , 2 , 2 ), m_account->accountId() , m_password );
271
				m_sid="loginnet.passport.com";
272
			else if( m_account->accountId().contains("@msn.com") ||  m_account->accountId().contains("@compaq.net") ||  m_account->accountId().contains("@webtv.net") )
273
				m_sid="msnialogin.passport.com";
274
			else
275
				m_sid="login.passport.com";
276
277
			QString authURL="https://"+m_sid+"/login.srf?" + m_authData;
278
			authURL.replace("," , "&" ) ;
279
280
			kdDebug(14140) << k_funcinfo << "downlaod URL: " << authURL << endl;
281
282
			KIO::Job *job = KIO::get( KURL( authURL ), true, false );
283
			job->addMetaData("cookies", "manual");
284
			// This should force kio to download the page even is we are in the konqueror offline mode.  [see bug #68483]
285
			job->addMetaData("cache", "reload");
286
			QObject::connect( job, SIGNAL(result( KIO::Job *)), this, SLOT(slotAuthJobDone( KIO::Job *)) );
287
		}
278
		}
288
		else
279
		else
289
		{
280
		{
Lines 570-645 Link Here
570
}
561
}
571
562
572
563
573
void MSNNotifySocket::slotAuthJobDataReceived ( KIO::Job */*job*/,const  QByteArray &data)
564
void MSNNotifySocket::sslLoginFailed()
574
{
565
{
575
	m_authData += QCString( data, data.size()+1 );
566
	disconnect();
576
//	kdDebug(14140) << "MSNNotifySocket::slotAuthJobDataReceived: " << data << endl;
577
}
567
}
578
568
void MSNNotifySocket::sslLoginIncorrect()
579
void MSNNotifySocket::slotAuthJobDone ( KIO::Job *job)
580
{
569
{
581
//	kdDebug(14140) << "MSNNotifySocket::slotAuthJobDone: "<< m_authData << endl;
570
	m_badPassword = true;
582
571
	disconnect();
583
	if(job->error())
572
}
584
	{
573
void MSNNotifySocket::sslLoginSucceeded(QString a)
585
		//FIXME: Shouldn't we say that we are the MSN plugin?
574
{
586
		job->showErrorDialog();
575
	sendCommand("USR" , "TWN S " + a);
587
		disconnect();
576
	m_sslLoginHandler->deleteLater();
588
		return;
577
	m_sslLoginHandler=0;
589
	}
590
591
	if(m_kv.isNull())
592
	{
593
		QStringList cookielist=QStringList::split("\n", job->queryMetaData("setcookies") );
594
		QString cookies="Cookie: ";
595
		for ( QStringList::Iterator it = cookielist.begin(); it != cookielist.end(); ++it )
596
		{
597
			QRegExp rx("Set-Cookie: ([^;]*)");
598
			rx.search(*it);
599
			cookies+=rx.cap(1)+";";
600
		}
601
602
		//QRegExp rx("lc=([1-9]*),id=([1-9]*),tw=([1-9]*),fs=[1-9]*,ru=[1-9a-zA-Z%]*,ct=[1-9]*,kpp=[1-9]*,kv=([1-9]*),");
603
		QRegExp rx("lc=([0-9]*),id=([0-9]*),tw=([0-9]*),.*kv=([0-9]*),");
604
		rx.search(m_authData);
605
606
		QString authURL = "https://" + m_sid + "/ppsecure/post.srf?lc=" + rx.cap( 1 ) + "&id=" +
607
			rx.cap( 2 ) + "&tw=" + rx.cap( 3 ) + "&cbid=" + rx.cap( 2 ) + "&da=passport.com&login=" +
608
			KURL::encode_string( m_account->accountId()) + "&domain=passport.com&passwd=";
609
610
		kdDebug( 14140 ) << k_funcinfo << "Download URL: " << authURL << "(*******)" << endl;
611
612
		m_authData = QString::null;
613
		m_kv=rx.cap(4);
614
		if(m_kv.isNull()) m_kv="";
615
616
		authURL += KURL::encode_string( m_password ) ;
617
		job = KIO::get( KURL( authURL ), false, false );
618
		job->addMetaData("cookies", "manual");
619
		job->addMetaData("setcookies", cookies);
620
		job->addMetaData("cache", "reload");
621
622
		QObject::connect( job, SIGNAL(data( KIO::Job *,const QByteArray&)), this, SLOT(slotAuthJobDataReceived( KIO::Job *,const QByteArray&)) );
623
		QObject::connect( job, SIGNAL(result( KIO::Job *)), this, SLOT(slotAuthJobDone( KIO::Job *)) );
624
	}
625
	else
626
	{
627
		if(m_authData.contains("CookiesDisabled"))
628
		{
629
			// FIXME: is this still possible now we add our meta data? - Martijn
630
			disconnect();
631
			KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error,
632
				i18n( "Unable to connect to the MSN Network.\nYour Web browser options are currently set to disable cookies.\n"
633
				"To use .NET Passport, you must enable cookies at least for the passport.com domain" ), i18n( "MSN Plugin" ) );
634
			return;
635
		}
636
637
		QRegExp rx(/*URL=http://memberservices.passport.net/memberservice.srf*/"\\?did=[0-9]*&(t=[0-9A-Za-z!$*]*&p=[0-9A-Za-z!$*]*)\"");
638
		rx.search(m_authData);
639
640
		m_badPassword=true;  //if this disconnect, that mean the password was bad
641
		sendCommand("USR" , "TWN S " + rx.cap(1));
642
	}
643
}
578
}
644
579
645
580
(-)kdenetwork-3.3.2/kopete/protocols/msn/msnnotifysocket.h (-3 / +5 lines)
Lines 29-34 Link Here
29
class MSNDispatchSocket;
29
class MSNDispatchSocket;
30
class MSNAccount;
30
class MSNAccount;
31
class KTempFile;
31
class KTempFile;
32
class SslLoginHandler;
32
33
33
#include <kio/job.h>
34
#include <kio/job.h>
34
35
Lines 138-145 Link Here
138
139
139
140
140
141
141
	void slotAuthJobDataReceived ( KIO::Job *, const QByteArray &data);
142
	void sslLoginFailed();
142
	void slotAuthJobDone ( KIO::Job *);
143
	void sslLoginIncorrect();
144
	void sslLoginSucceeded(QString);
143
145
144
146
145
private:
147
private:
Lines 171-177 Link Here
171
	QString m_kv;
173
	QString m_kv;
172
	QString m_sid;
174
	QString m_sid;
173
	QString m_loginTime;
175
	QString m_loginTime;
174
	QString m_authData;
176
	SslLoginHandler *m_sslLoginHandler;
175
177
176
	QTimer *m_keepaliveTimer;
178
	QTimer *m_keepaliveTimer;
177
179
(-)kdenetwork-3.3.2/kopete/protocols/msn/msnsocket.cpp (-1 / +1 lines)
Lines 133-139 Link Here
133
133
134
void MSNSocket::slotSocketError( int error )
134
void MSNSocket::slotSocketError( int error )
135
{
135
{
136
	kdDebug( 14140 ) << k_funcinfo << "Error: " << error << endl;
136
	kdWarning( 14140 ) << k_funcinfo << "Error: " << error << " (" << m_socket->errorString() << ")" << endl;
137
137
138
	QString errormsg = i18n( "There was an error while connecting to the MSN server.\nError message:\n" );
138
	QString errormsg = i18n( "There was an error while connecting to the MSN server.\nError message:\n" );
139
	if ( error == KSocketBase::LookupFailure )
139
	if ( error == KSocketBase::LookupFailure )
(-)kdenetwork-3.3.2/kopete/protocols/msn/sslloginhandler.cpp (+453 lines)
Line 0 Link Here
1
//Imported from KMess (2005-05-19)
2
3
/***************************************************************************
4
                          sslloginhandler.cpp  -  description
5
                             -------------------
6
    begin                : Sat Jun 28 2003
7
    copyright            : (C) 2003 by Mike K. Bennett
8
    email                : mkb137b@hotmail.com
9
 ***************************************************************************/
10
11
/***************************************************************************
12
 *                                                                         *
13
 *   This program is free software; you can redistribute it and/or modify  *
14
 *   it under the terms of the GNU General Public License as published by  *
15
 *   the Free Software Foundation; either version 2 of the License, or     *
16
 *   (at your option) any later version.                                   *
17
 *                                                                         *
18
 ***************************************************************************/
19
20
#include "sslloginhandler.h"
21
22
#include <qstringlist.h>
23
#include <qregexp.h>
24
#include <qsocket.h>
25
#include <qurl.h>
26
27
#include <kdebug.h>
28
#include <kextsock.h>
29
#include <kssl.h>
30
#include <kurl.h>
31
32
#if 0
33
#include "../kmessdebug.h"
34
#include "mimemessage.h"
35
#else
36
//i didn't want to import the whole MimeMessage from Kmess for Kopete so i
37
// reimplemented the base here  -Olivier
38
39
class MimeMessage
40
{
41
	public:
42
		MimeMessage(const QString &msg) : message(msg) {}
43
44
		QString getValue(const QString &key)
45
		{
46
			QRegExp rx(key+": (.*)\n");
47
			rx.search(message);
48
			return rx.cap(1);
49
		}
50
	private:
51
		QString message;
52
};
53
54
#include "sslloginhandler.moc"
55
#endif
56
//there is nothing modified from here.  this is exactly the kmerlin code
57
58
59
60
/*
61
 * Great documentation about this can be found at
62
 * http://siebe.bot2k3.net/docs/
63
 */
64
65
66
// The constructor
67
SslLoginHandler::SslLoginHandler()
68
 : mode_(NONE)
69
{
70
  // Create the SSL handler
71
  ssl_ = new KSSL( true );
72
73
  // Create and set up the socket.
74
  socket_ = new KExtendedSocket( );
75
76
  //socket_->setSocketFlags( 0x00 | 0x600000 ); // 0x00 = anySocket | 0x600000 = bufferedSocket
77
  socket_->setSocketFlags( 0x00 ); // 0x00 = anySocket | 0x600000 = bufferedSocket
78
  socket_->setTimeout( 30   );
79
  socket_->enableRead( true );
80
  connect( socket_, SIGNAL(         readyRead()    ),
81
           this,    SLOT  (      dataReceived()    ) );
82
  connect( socket_, SIGNAL(  connectionFailed(int) ),
83
           this,    SLOT  (       socketError(int) ) );
84
}
85
86
87
88
// The destructor
89
SslLoginHandler::~SslLoginHandler()
90
{
91
  delete ssl_;
92
  delete socket_;
93
}
94
95
96
97
// Data was received over the socket
98
void SslLoginHandler::dataReceived()
99
{
100
#ifdef KMESSDEBUG_SSLLOGINHANDLER
101
  kdDebug() << "SslLoginHandler - ******************** Data received ********************" << endl;
102
  kdDebug() << "SslLoginHandler - " << socket_->bytesAvailable() << " bytes available." << endl;
103
  kdDebug() << "SslLoginHandler - SSL says " << ssl_->pending() << " bytes available." << endl;
104
#endif
105
106
  QString   data;
107
  int       breakOut = 0;
108
  const int maxIterations = 1000;
109
  while ( ( !data.contains( QRegExp("\r\n") ) ) && ( breakOut < maxIterations ) )
110
  {
111
    // Read data via SSL
112
    data = readSslData();
113
    breakOut ++;
114
  }
115
116
  // Output the data for debugging
117
#ifdef KMESSDEBUG_SSLLOGINHANDLER
118
  kdDebug() << "SslLoginHandler - ********************   Contents    ********************" << endl;
119
  kdDebug() << data << endl;
120
  kdDebug() << "SslLoginHandler - ********************  End of data  ********************" << endl;
121
#endif
122
123
  // Warn if timed out
124
  if ( breakOut >= maxIterations )
125
  {
126
    kdDebug() << "WARNING - SSL read timed out." << endl;
127
    emit loginFailed();
128
    return;
129
  }
130
131
  if ( data.length() > 0 )
132
  {
133
    parseHttpResponse(data);
134
  }
135
  else
136
  {
137
    kdDebug() << "WARNING - Available data wasn't read from the SSL socket." << endl;
138
    emit loginFailed();
139
  }
140
}
141
142
143
144
// Start the login process
145
void SslLoginHandler::login( QString parameters, QString handle, QString password )
146
{
147
#ifdef KMESSDEBUG_SSLLOGINHANDLER
148
  kdDebug() << "SslLoginHandler - Starting login with parameters " << parameters << "." << endl;
149
#endif
150
151
  // Store the given data
152
  authenticationParameters_ = parameters;
153
  handle_                   = handle;
154
  password_                 = password;
155
156
  // Get the login server
157
  sendLoginServerRequest("nexus.passport.com");
158
  dataReceived();
159
}
160
161
162
163
// Get the authentication data from a string
164
void SslLoginHandler::parseAuthenticationData( QString data )
165
{
166
  QString twnData;
167
168
  // Pull TWN data out of the message
169
  twnData = data.right( data.length() - data.find(QRegExp("from-PP='")) - 9 );
170
  twnData = twnData.left( twnData.find(QRegExp("',")) );
171
172
#ifdef KMESSDEBUG_SSLLOGINHANDLER
173
  kdDebug() << "SslLoginHandler - data for TWN is " << twnData << "." << endl;
174
#endif
175
176
  // Notify the MsnNotificationConnection
177
  emit loginSucceeded(twnData);
178
}
179
180
181
182
// Parse the HTTP response from the server
183
void SslLoginHandler::parseHttpResponse(QString data)
184
{
185
  KURL    location;
186
  int     headerEnd;
187
  QString header;
188
  int     headerCode;
189
  QString headerText;
190
191
  // Parse the HTTP status header
192
  QRegExp re("HTTP/\\d+\\.\\d+ (\\d+) ([^\r\n]+)");
193
  headerEnd  = data.find("\r\n");
194
  header     = data.left( (headerEnd == -1) ? 20 : headerEnd );
195
196
  re.search(header);
197
  headerCode = re.cap(1).toUInt();
198
  headerText = re.cap(2);
199
200
  // Create a MimeMessage, removing the HTTP status header
201
  MimeMessage message( data.section( ",", 1 ) );
202
203
204
  switch(mode_)
205
  {
206
    case GETLOGINSERVER:
207
    {
208
      // Step 1. This data describes the login server to use.
209
      if(headerCode == 302)
210
      {
211
        // HTTP Redirect
212
        location = KURL( message.getValue( "Location" ) );
213
        sendLoginServerRequest(location.host());
214
      }
215
      else
216
      {
217
        // Parse the data
218
        QString loginServer;
219
        QString page;
220
        parseLoginServerData( loginServer, page, message.getValue("PassportURLs") );
221
222
        // Send the authentication request
223
        sendAuthenticationRequest( loginServer, page );
224
      }
225
      break;
226
    }
227
    case GETAUTHENTICATIONDATA:
228
    {
229
      // Step 2. Get the authentication data
230
      if(headerCode == 200)
231
      {
232
        // Login success
233
        parseAuthenticationData(message.getValue("Authentication-Info"));
234
      }
235
      else if(headerCode == 302)
236
      {
237
        // HTTP Redirect
238
        location = KURL( message.getValue( "Location" ) );
239
        sendAuthenticationRequest(location.host(), location.path());
240
      }
241
      else if(headerCode == 401)
242
      {
243
        // Got a HTTP "401 Unauthorized"; Login failed
244
        emit loginIncorrect();
245
      }
246
      else
247
      {
248
        kdDebug() << "SslLoginHandler::parseHttpResponse: WARNING "
249
                  << "- Unhandled response code " << headerCode << " " << headerText << endl;
250
        emit loginFailed();
251
      }
252
      break;
253
    }
254
    default:
255
    {
256
      kdDebug() << "SslLoginHandler::parseHttpResponse: WARNING - Entered illegal state" << endl;
257
      emit loginFailed();
258
    }
259
  }
260
}
261
262
263
// Get login server data from a string
264
void SslLoginHandler::parseLoginServerData( QString &host, QString &page, QString serverData )
265
{
266
  int slashIndex;
267
268
  // Get everything between "DLLogin=" and to the comma.
269
  serverData = serverData.right( serverData.length() - serverData.find( "DALogin=" ) - 8 );
270
  serverData = serverData.left( serverData.find( "," ) );
271
272
#ifdef KMESSDEBUG_SSLLOGINHANDLER
273
  kdDebug() << "SslLoginHandler - host/page=" << serverData << endl;
274
#endif
275
276
  // Separate the "host/page" string.
277
  slashIndex = serverData.find( "/" );
278
  host = serverData.left( slashIndex );
279
  page = serverData.right( serverData.length() - slashIndex );
280
281
#ifdef KMESSDEBUG_SSLLOGINHANDLER
282
  kdDebug() << "SslLoginHandler - host=" << host << " page=" << page << endl;
283
#endif
284
}
285
286
287
288
// Read data from the socket via SSL
289
QString SslLoginHandler::readSslData()
290
{
291
  char       rawblock[1024];
292
  QCString   block;
293
  QString    data        = "";
294
  int        noBytesRead = 1;
295
296
  // Read data from the SSL socket.
297
  if ( ssl_ != 0 )
298
  {
299
//    while( ( ssl_->pending() > 0 ) && ( noBytesRead > 0 ) )
300
//    while( ( socket_->bytesAvailable() > 0 ) && ( noBytesRead > 0 ) )
301
    while(noBytesRead > 0)
302
    {
303
      noBytesRead = ssl_->read( rawblock, 1024 );
304
#ifdef KMESSDEBUG_SSLLOGINHANDLER
305
      kdDebug() << "SslLoginHandler - " << noBytesRead << " bytes read." << endl;
306
#endif
307
      block = rawblock;
308
      block = block.left( noBytesRead );
309
      data += QString::fromUtf8( block );
310
    }
311
  }
312
313
  return data;
314
}
315
316
317
318
// Send the authenticationn request
319
void SslLoginHandler::sendAuthenticationRequest( QString loginServer, QString page )
320
{
321
#ifdef KMESSDEBUG_SSLLOGINHANDLER
322
  kdDebug() << "SslLoginHandler - Step 2. Requesting authentication data." << endl;
323
#endif
324
325
  QString request;
326
  QString encodedHandle   = handle_;
327
  QString encodedPassword = password_;
328
329
  QUrl::encode(encodedHandle);
330
  QUrl::encode(encodedPassword);
331
332
  request = "GET " + page + " HTTP/1.1\r\n"
333
            "Authorization: Passport1.4"
334
              " OrgVerb=GET"
335
              ",OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom"
336
              ",sign-in=" + encodedHandle +
337
              ",pwd="     + encodedPassword +
338
              ","         + authenticationParameters_ + "\r\n"
339
            "User-Agent: MSMSGS\r\n"     // Make sure the server won't discriminate
340
            "Host: " + loginServer + "\r\n"
341
            "Connection: Keep-Alive\r\n"
342
            "Cache-Control: no-cache\r\n\r\n";
343
344
  // Step 2. Send the authorisation request
345
  mode_ = GETAUTHENTICATIONDATA;
346
  sendHttpRequest( request, loginServer, 443 );
347
}
348
349
350
351
// Send a HTTP request to the server
352
void SslLoginHandler::sendHttpRequest( QString request, QString host, int port )
353
{
354
  QString response;
355
  QString responseBody;
356
357
  if ( socket_ == 0 )
358
  {
359
    kdDebug() << "SslLoginHandler::sendHttpRequest - WARNING "
360
              << "- Trying to login using a null socket." << endl;
361
    return;
362
  }
363
364
  // Configure the socket
365
#ifdef KMESSDEBUG_SSLLOGINHANDLER
366
  kdDebug() << "SslLoginHandler - Close and reset the socket." << endl;
367
#endif
368
  ssl_->setAutoReconfig( true );
369
  ssl_->reInitialize();
370
  socket_->closeNow();
371
  socket_->reset();
372
373
  // Try to connect
374
#ifdef KMESSDEBUG_SSLLOGINHANDLER
375
  kdDebug() << "SslLoginHandler - Connecting to " << host << ":" << port << "." << endl;
376
#endif
377
  socket_->setAddress( host, port );
378
  socket_->lookup();
379
  int connectionSuccess = socket_->connect();
380
  if ( connectionSuccess != 0 )
381
  {
382
    kdDebug() << "SslLoginHandler::sendHttpRequest - WARNING "
383
              << "- Connection failed, giving " << connectionSuccess << endl;
384
    return;
385
  }
386
387
  // Try to wrap the SSL handler
388
#ifdef KMESSDEBUG_SSLLOGINHANDLER
389
  kdDebug() << "SslLoginHandler - Connection success, binding SSL to socket fd " << socket_->fd() << endl;
390
#endif
391
  int sslConnectionSuccess = ssl_->connect( socket_->fd() );
392
  if ( sslConnectionSuccess != 1 )
393
  {
394
    kdDebug() << "SslLoginHandler::sendHttpRequest - WARNING "
395
              << "- SSL Connection failed, giving " << sslConnectionSuccess << endl;
396
    return;
397
  }
398
399
  // Send the request
400
#ifdef KMESSDEBUG_SSLLOGINHANDLER
401
  kdDebug() << "SslLoginHandler - SSL connected OK, sending the request." << endl;
402
  kdDebug() << request;
403
#endif
404
  writeSslData( request );
405
}
406
407
408
409
// Request the name of the login server
410
void SslLoginHandler::sendLoginServerRequest(QString hostname)
411
{
412
#ifdef KMESSDEBUG_SSLLOGINHANDLER
413
  kdDebug() << "SslLoginHandler - Step 1. Requesting the login server." << endl;
414
#endif
415
416
  // Step 1. Send the login server request
417
  // The server will respond with the location of the main SSL server.
418
  mode_ = GETLOGINSERVER;
419
  sendHttpRequest( "GET /rdr/pprdr.asp\r\n\r\n", hostname, 443 );
420
}
421
422
423
424
// Detect a socket error
425
void SslLoginHandler::socketError(int error)
426
{
427
  kdDebug() << "SslLoginHandler : WARNING - Received error " << error << " from the socket." << endl;
428
}
429
430
431
432
// Write data to the socket via SSL
433
void SslLoginHandler::writeSslData( QString data )
434
{
435
  int noBytesWritten;
436
437
  if(socket_ != 0 && ssl_ != 0)
438
  {
439
    noBytesWritten = ssl_->write( data.latin1(), data.length() );
440
    if(noBytesWritten != (int)data.length())
441
    {
442
      kdDebug() << "WARNING - Wanted to write " << data.length() << " to the socket, "
443
                << " wrote " << noBytesWritten << "." << endl;
444
    }
445
#ifdef KMESSDEBUG_SSLLOGINHANDLER
446
    else
447
    {
448
      kdDebug() << "SslLoginHandler - Sent " << noBytesWritten << " bytes via SSL." << endl;
449
    }
450
#endif
451
  }
452
}
453
(-)kdenetwork-3.3.2/kopete/protocols/msn/sslloginhandler.h (+96 lines)
Line 0 Link Here
1
//Imported from KMess  - 2005-05-19
2
3
/***************************************************************************
4
                          sslloginhandler.h  -  description
5
                             -------------------
6
    begin                : Sat Jun 28 2003
7
    copyright            : (C) 2003 by Mike K. Bennett
8
    email                : mkb137b@hotmail.com
9
 ***************************************************************************/
10
11
/***************************************************************************
12
 *                                                                         *
13
 *   This program is free software; you can redistribute it and/or modify  *
14
 *   it under the terms of the GNU General Public License as published by  *
15
 *   the Free Software Foundation; either version 2 of the License, or     *
16
 *   (at your option) any later version.                                   *
17
 *                                                                         *
18
 ***************************************************************************/
19
20
#ifndef SSLLOGINHANDLER_H
21
#define SSLLOGINHANDLER_H
22
23
#include <qobject.h>
24
#include <qstringlist.h>
25
26
// Forward declarations
27
class KExtendedSocket;
28
class KSSL;
29
class MimeMessage;
30
31
/**This class handles the SSL portion of the login.
32
  *@author Mike K. Bennett
33
  */
34
35
class SslLoginHandler : public QObject
36
{
37
   Q_OBJECT
38
39
  public:
40
    // The constructor
41
                         SslLoginHandler();
42
    // The destructor
43
                        ~SslLoginHandler();
44
    // Start the login process
45
    void                 login( QString parameters, QString handle, QString password );
46
47
  private : // Private methods
48
    // Get the authentication data from a string
49
    void                 parseAuthenticationData( QString data );
50
    // Parse the HTTP response from the server
51
    void                 parseHttpResponse(QString data);
52
    // Get login server data from a string
53
    void                 parseLoginServerData( QString &host, QString &page, QString serverData );
54
    // Read data from the socket via SSL
55
    QString              readSslData();
56
    // Send the authenticationn request
57
    void                 sendAuthenticationRequest( QString loginServer, QString page );
58
    // Send a HTTP request to the server
59
    void                 sendHttpRequest( QString request, QString host, int port );
60
    // Request the name of the login server
61
    void                 sendLoginServerRequest(QString hostname);
62
    // Write data to the socket via SSL
63
    void                 writeSslData( QString data );
64
65
  private slots : // Private slots
66
    // Data was received over the socket
67
    void                 dataReceived();
68
    // Detect a socket error
69
    void                 socketError(int error);
70
71
  private : // Private attributes
72
    // The mode of the transfer.
73
    enum Mode          { NONE = 0, GETLOGINSERVER = 1, GETAUTHENTICATIONDATA = 2 } mode_;
74
    // The list of parameters sent by the notification server
75
    QString              authenticationParameters_;
76
    // The cookies we received from the server
77
    QStringList          cookies_;
78
    // The user's handle
79
    QString              handle_;
80
    // The user's password
81
    QString              password_;
82
    // The socket over which the SSL data is written and read
83
    KExtendedSocket     *socket_;
84
    // The SSL handler
85
    KSSL                *ssl_;
86
87
  signals : // Public signals
88
    // Signal that the login was aborted because an internal error occured
89
    void                 loginFailed();
90
    // Signal that the login failed, username/password was incorrect
91
    void                 loginIncorrect();
92
    // Signal that the login succeeded
93
    void                 loginSucceeded( QString authentication );
94
};
95
96
#endif

Return to bug 93213