diff -ruN kruiser-0.4/src/OptionsSMB.cc kruiser-0.4-gr/src/OptionsSMB.cc --- kruiser-0.4/src/OptionsSMB.cc Thu Jan 6 17:53:23 2000 +++ kruiser-0.4-gr/src/OptionsSMB.cc Sun May 14 19:49:54 2000 @@ -44,6 +44,7 @@ connect(Update,SIGNAL(clicked()),SLOT(updateClicked())); ShowHiddenShares = new QCheckBox(i18n("Show hidden shares"),this); + TryGuestLogin = new QCheckBox(i18n("Try guest login first"),this); SambaVersion = new QComboBox(this); SambaVersion->insertItem("2.0.3"); @@ -110,7 +111,8 @@ Remove->setGeometry(90+space2,current,80,30); Update->setGeometry(170+2*space2,current,80,30); current += (30+space); - ShowHiddenShares->setGeometry(10,current,width()-20,25); + ShowHiddenShares->setGeometry(10,current,(width()-20)/2,25); + TryGuestLogin->setGeometry(10+(width()-20)/2,current, (width()-20)/2,25); current += (25+space); w = (width()-20)/2; SambaLabel->setGeometry(10,current,w,25); @@ -156,6 +158,7 @@ ComputerList.insert(0,item); } ShowHiddenShares->setChecked(conf->readBoolEntry("ShowHiddenShares",false)); + TryGuestLogin->setChecked(conf->readBoolEntry("TryGuestLogin",false)); Modified = false; } @@ -175,5 +178,6 @@ conf->writeEntry("ComputerIP",start); } conf->writeEntry("ShowHiddenShares",ShowHiddenShares->isChecked()); + conf->writeEntry("TryGuestLogin",TryGuestLogin->isChecked()); Modified = false; } diff -ruN kruiser-0.4/src/OptionsSMB.h kruiser-0.4-gr/src/OptionsSMB.h --- kruiser-0.4/src/OptionsSMB.h Thu Jan 6 17:42:23 2000 +++ kruiser-0.4-gr/src/OptionsSMB.h Sun May 14 19:41:14 2000 @@ -46,6 +46,7 @@ QComboBox *SambaVersion; QComboBox *IPType; QCheckBox *ShowHiddenShares; + QCheckBox *TryGuestLogin; }; -#endif \ No newline at end of file +#endif diff -ruN kruiser-0.4/src/protmgr.cc kruiser-0.4-gr/src/protmgr.cc --- kruiser-0.4/src/protmgr.cc Wed Jan 5 12:16:13 2000 +++ kruiser-0.4-gr/src/protmgr.cc Sun May 14 20:27:04 2000 @@ -259,21 +259,31 @@ return retval; } +bool ProtocolMgr::getLogin(Protocol *prot) +{ + LineDlg *Dlg = new LineDlg(0,0,2); + QString str(i18n("Password required")); + Dlg->setCaption(str.data()); + // Dlg->setLabel(prot->prefix().data()); + Dlg->setLabel(i18n("User"),1); + Dlg->setLabel(i18n("Password"),2); + QString user = prot->user(); + if (user.isEmpty()) user = getenv("USER"); + Dlg->setText(user.data(),1,true); + Dlg->setPasswd(); + if (Dlg->exec()) { + prot->setLogin(Dlg->text(1),Dlg->text(2)); + return true; + } + else + return false; +} + bool ProtocolMgr::initProtocol(Protocol *prot) { if (prot->needLogin()) { - LineDlg *Dlg = new LineDlg(0,0,2); - QString str(i18n("Password required")); - Dlg->setCaption(str.data()); -// Dlg->setLabel(prot->prefix().data()); - Dlg->setLabel(i18n("User"),1); - Dlg->setLabel(i18n("Password"),2); - QString user = prot->user(); - if (user.isEmpty()) user = getenv("USER"); - Dlg->setText(user.data(),1,true); - Dlg->setPasswd(); - if (Dlg->exec()) prot->setLogin(Dlg->text(1),Dlg->text(2)); - else return false; + if (!getLogin(prot)) + return false; } return thread_routine1(PROTOCOL_INIT,(void*)prot); } diff -ruN kruiser-0.4/src/protmgr.h kruiser-0.4-gr/src/protmgr.h --- kruiser-0.4/src/protmgr.h Mon Oct 11 13:47:07 1999 +++ kruiser-0.4-gr/src/protmgr.h Sun May 14 20:27:48 2000 @@ -56,6 +56,7 @@ void abort(); void showError(const char*); bool initProtocol(Protocol *prot); + bool getLogin(Protocol *prot); bool finishProtocol(Protocol *prot); void reset(); void loadImage(FileInfo *fi, int save, int size); diff -ruN kruiser-0.4/src/smb.cc kruiser-0.4-gr/src/smb.cc --- kruiser-0.4/src/smb.cc Thu Jan 6 17:41:47 2000 +++ kruiser-0.4-gr/src/smb.cc Sun May 14 21:08:00 2000 @@ -384,6 +384,8 @@ ShareList->setAutoDelete(false); Prefix = "smb://" + Name + "/"; UpdateFlag = true; + kapp->getConfig()->setGroup("Configuration"); + GuestLogin = kapp->getConfig()->readBoolEntry("TryGuestLogin",false); } SMBMachine::~SMBMachine() @@ -401,7 +403,19 @@ { if (UpdateFlag) { sendMessage("Scanning shares..."); - if (!getShareList()) return 0; + if (GuestLogin) { + User = "guest"; + Passwd = ""; + if (!getShareList()) { + GuestLogin = false; + ((ProtocolMgr*)Manager)->getLogin(this); + if (!getShareList()) + return false; + } + } else { + if (!getShareList()) + return false; + } translateShareList(); } filterEntries(dirsOnly); diff -ruN kruiser-0.4/src/smb.h kruiser-0.4-gr/src/smb.h --- kruiser-0.4/src/smb.h Mon Dec 13 11:08:21 1999 +++ kruiser-0.4-gr/src/smb.h Sun May 14 20:59:41 2000 @@ -76,7 +76,7 @@ void cleanProtocols(); bool matchURL(KURL url); bool cleanup(); - bool needLogin() { return (UpdateFlag && (User.isEmpty() || (!User.isEmpty() && Passwd.isEmpty())));}; + bool needLogin() { return (!GuestLogin && UpdateFlag && (User.isEmpty() || (!User.isEmpty() && Passwd.isEmpty())));}; void setLogin(const char *user, const char *pwd) { User = user; Passwd = pwd;} const char* user() { return User.data();} const char* passwd() { return Passwd.data();} @@ -98,6 +98,7 @@ QString Passwd; QList *ShareList; bool UpdateFlag; + bool GuestLogin; }; class SMBShare : public SmbProtocol diff -ruN kruiser-0.4/src/smbprot.cc kruiser-0.4-gr/src/smbprot.cc --- kruiser-0.4/src/smbprot.cc Tue Dec 7 14:53:50 1999 +++ kruiser-0.4-gr/src/smbprot.cc Sun May 14 21:11:07 2000 @@ -45,6 +45,8 @@ Prefix += MountPoint; if (Prefix.right(1) != "/") Prefix += '/'; Mounted = false; + kapp->getConfig()->setGroup("Configuration"); + GuestLogin = kapp->getConfig()->readBoolEntry("TryGuestLogin",false); } bool SmbProtocol::mount() @@ -69,7 +71,7 @@ case 2: // 2.0.6 cmd += (" " + processForShell(MountPoint) + " -o "); - if (User.isEmpty()) cmd += "guest"; + if (User.isEmpty() || GuestLogin) cmd += "guest"; else cmd += ("username=" + processForShell(User) + ",password=" + processForShell(Passwd)); if (!IP.isEmpty()) cmd += (",ip=" + IP); if (!Workgroup.isEmpty()) cmd += (",workgroup=" + Workgroup); @@ -87,6 +89,8 @@ Mounted = true; return TRUE; error: + if (GuestLogin) + GuestLogin = 0; ErrorMsg = i18n("Unable to mount device"); return FALSE; } diff -ruN kruiser-0.4/src/smbprot.h kruiser-0.4-gr/src/smbprot.h --- kruiser-0.4/src/smbprot.h Wed Dec 8 17:15:03 1999 +++ kruiser-0.4-gr/src/smbprot.h Sun May 14 21:07:35 2000 @@ -25,7 +25,7 @@ bool isLocal() { return false;} const char* passwd() { return (Passwd.isEmpty() ? "" : Passwd.data());} const char* user() { return (User.isEmpty() ? "" : User.data());} - bool needLogin() { return (!Mounted && (!User.isEmpty() && Passwd.isEmpty()));} + bool needLogin() { return (!GuestLogin && !Mounted && (!User.isEmpty() && Passwd.isEmpty()));} void setLogin(const char *user, const char *pwd) { User = user; Passwd = pwd;} bool check(); @@ -45,6 +45,7 @@ QString Server, Workgroup, Share; bool Mounted; + bool GuestLogin; }; inline SmbProtocol::~SmbProtocol()