diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 5741a4360..2ae2b12df 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -340,7 +340,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) menu->addAction(_appAct); #endif menu->addAction(_prefsAct); - menu->addAction(_smplayerAct); + //menu->addAction(_smplayerAct); menu->addAction(_helpAct); menu->addSeparator(); menu->addAction(QIcon(IMAGE_MINIMIZE), tr("Minimize"), this, SLOT(showMinimized())); @@ -543,7 +543,7 @@ MainWindow::~MainWindow() { delete _bandwidthGraph; delete _messengerwindowAct; - delete _smplayerAct; + //delete _smplayerAct; delete _preferencesWindow; } @@ -695,6 +695,7 @@ void MainWindow::showsmplayer() { return; +#if 0 if (mSMPlayer == 0) { mSMPlayer = new SMPlayer(QString::null, this); @@ -704,12 +705,25 @@ void MainWindow::showsmplayer() { mSMPlayer->gui()->show(); } +#endif } void MainWindow::playFiles(QStringList files) { - std::cerr << "MainWindow::playFiles()" << std::endl; + std::cerr << "MainWindow::playFiles() Can only play first currently" << std::endl; + QStringList::iterator it; + it = files.begin(); + if (it == files.end()) + { + return; + } + std::string path = (*it).toStdString(); + std::cerr << "MainWindow::playFiles() opening: " << path << std::endl; + openFile(path); + return; + +#if 0 showsmplayer(); std::cerr << "MainWindow::playFiles() showsmplayer() done" << std::endl; @@ -718,6 +732,7 @@ void MainWindow::playFiles(QStringList files) mSMPlayer->gui()->openFiles(files); std::cerr << "MainWindow::playFiles() done" << std::endl; +#endif } @@ -765,3 +780,67 @@ MainWindow::showPreferencesWindow(PreferencesWindow::Page page) } + +void openFile(std::string path) +{ + bool isAbs = true; + QString surl("file://"); + +#if defined(Q_OS_WIN) + /* check that it is an absolute path */ + if (path.size() < 4) + { + std::cerr << "[WIN] openPath() Very Small path ignoring: " << path; + std::cerr << std::endl; + return + } + + if ((path[1] == ':') && (path.[2] == '\')) + { + isAbs = true; + } +#else + + /* check that it is an absolute path */ + if (path.size() < 1) + { + std::cerr << "[UNIX] openPath() Very Small path ignoring: " << path; + std::cerr << std::endl; + return; + } + + if (path[0] == '/') + { + isAbs = true; + } +#endif + + if (!isAbs) + { + +#define ROOT_PATH_SIZE 1024 + + char rootdir[ROOT_PATH_SIZE]; + if (NULL == getcwd(rootdir, ROOT_PATH_SIZE)) + { + std::cerr << "openPath() get Abs Failed: " << path; + std::cerr << std::endl; + return; + } + + std::string rdir(rootdir); + surl += QString::fromStdString(rdir); + surl += '/'; + } + + surl += QString::fromStdString(path); + std::cerr << "openPath() opening AbsPath Url: " << surl.toStdString(); + std::cerr << std::endl; + + QUrl url(surl); + QDesktopServices::openUrl(url); + + return; +} + + diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 1bb5ead1b..7eb34d044 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -59,6 +59,8 @@ class SMPlayer; class PeerStatus; +void openFile(std::string path); + class MainWindow : public RWindow { Q_OBJECT diff --git a/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp index 0e3681b08..d32e9cff5 100644 --- a/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp @@ -118,6 +118,7 @@ void ChanMsgItem::updateItemStatic() /* don't really want this at all! */ unsubscribeButton->hide(); + playButton->hide(); } @@ -141,10 +142,16 @@ void ChanMsgItem::updateItem() return; } } + + /*** + * At this point cannot create a playlist.... + * so can't enable play for all. + if (mFileItems.size() > 0) { playButton->setEnabled(true); } + ***/ } diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.cpp b/retroshare-gui/src/gui/feeds/SubFileItem.cpp index c37c11a5b..ffc3d02ac 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/SubFileItem.cpp @@ -24,13 +24,15 @@ #include "rsiface/rsfiles.h" +/* hack for openFile() */ +#include "gui/MainWindow.h" + #include /**** * #define DEBUG_ITEM 1 ****/ - /******************************************************************* * SubFileItem fully controls the file transfer from the gui side * @@ -121,6 +123,11 @@ void SubFileItem::Setup() /* once off check - if remote, check if we have it * NB: This check might be expensive - and it'll happen often! */ +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::Setup(): " << mFileName; + std::cerr << std::endl; +#endif + if (mMode == SFI_STATE_REMOTE) { FileInfo fi; @@ -130,6 +137,12 @@ void SubFileItem::Setup() /* look up path */ if (rsFiles->FileDetails(mFileHash, hintflags, fi)) { +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::Setup() STATE=>Local Found File"; + std::cerr << std::endl; + std::cerr << "SubFileItem::Setup() path: " << fi.path; + std::cerr << std::endl; +#endif mMode = SFI_STATE_LOCAL; mPath = fi.path; } @@ -157,7 +170,7 @@ void SubFileItem::updateItemStatic() { /* fill in */ #ifdef DEBUG_ITEM - std::cerr << "SubFileItem::updateItemStatic()"; + std::cerr << "SubFileItem::updateItemStatic(): " << mFileName; std::cerr << std::endl; #endif @@ -184,10 +197,12 @@ void SubFileItem::updateItemStatic() } /* get full path for local file */ - // TMP DISABLED FOR DEMONSTRATOR.... XXX -#if 0 if ((mMode == SFI_STATE_LOCAL) || (mMode == SFI_STATE_UPLOAD)) { +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItemStatic() STATE=Local/Upload checking path"; + std::cerr << std::endl; +#endif if (mPath == "") { FileInfo fi; @@ -198,15 +213,21 @@ void SubFileItem::updateItemStatic() if (!rsFiles->FileDetails(mFileHash, hintflags, fi)) { mMode = SFI_STATE_ERROR; +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItemStatic() STATE=>Error No Details"; + std::cerr << std::endl; +#endif } else { - // XXX CHECK VALID PATH! +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItemStatic() Updated Path"; + std::cerr << std::endl; +#endif mPath = fi.path; } } } -#endif /* do buttons + display */ switch (mMode) @@ -282,11 +303,6 @@ void SubFileItem::updateItemStatic() break; } - /* TMP Disable of Play Button - until media player - * issues are sorted. - */ - - playButton->setEnabled(false); saveButton->hide(); switch(mType) @@ -327,7 +343,7 @@ void SubFileItem::updateItem() { /* fill in */ #ifdef DEBUG_ITEM - std::cerr << "SubFileItem::updateItem()"; + std::cerr << "SubFileItem::updateItem():" << mFileName; std::cerr << std::endl; #endif @@ -340,13 +356,25 @@ void SubFileItem::updateItem() if ((mMode == SFI_STATE_ERROR) || (mMode == SFI_STATE_LOCAL)) { +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() STATE=Local/Error ignore"; + std::cerr << std::endl; +#endif /* ignore - dead file, or done */ } else if (mMode == SFI_STATE_EXTRA) { +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() STATE=Extra File"; + std::cerr << std::endl; +#endif /* check for file status */ if (rsFiles->ExtraFileStatus(mPath, fi)) { +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() STATE=>Local"; + std::cerr << std::endl; +#endif mMode = SFI_STATE_LOCAL; /* fill in file details */ @@ -381,18 +409,34 @@ void SubFileItem::updateItem() switch(mMode) { case SFI_STATE_REMOTE: +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() STATE=Remote"; + std::cerr << std::endl; +#endif /* is it downloading? */ if (detailsOk) { +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() STATE=>Download"; + std::cerr << std::endl; +#endif /* downloading */ mMode = SFI_STATE_DOWNLOAD; stateChanged = true; } break; case SFI_STATE_DOWNLOAD: +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() STATE=Download"; + std::cerr << std::endl; +#endif if (!detailsOk) { +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() STATE=>Remote"; + std::cerr << std::endl; +#endif mMode = SFI_STATE_REMOTE; stateChanged = true; } @@ -401,6 +445,10 @@ void SubFileItem::updateItem() /* has it completed? */ if (fi.avail == mFileSize) { +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() STATE=>Local"; + std::cerr << std::endl; +#endif /* save path */ /* update progress */ mMode = SFI_STATE_LOCAL; @@ -411,6 +459,10 @@ void SubFileItem::updateItem() } break; case SFI_STATE_UPLOAD: +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() STATE=Upload"; + std::cerr << std::endl; +#endif if (detailsOk) { @@ -464,6 +516,10 @@ void SubFileItem::updateItem() if (repeat) { +#ifdef DEBUG_ITEM + std::cerr << "SubFileItem::updateItem() callback for update!"; + std::cerr << std::endl; +#endif QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); } @@ -519,11 +575,12 @@ void SubFileItem::cancel() void SubFileItem::play() { #ifdef DEBUG_ITEM - std::cerr << "SubFileItem::play()"; + std::cerr << "SubFileItem::play() :" << mPath; std::cerr << std::endl; #endif - /* Only occurs - if it is local / uploading (have mPath set) */ - rsFiles->FileCancel(mFileHash); + + openFile(mPath); + } void SubFileItem::download()