mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-24 07:00:57 -04:00
Channels
- removed settings button - deals with hashing of its own files subfileitem - absolved from file hashing responsibility - added play button functionality(taken from transfer dialog, thanks) blog - removed file attachments feature (only for blogging ), will add pic support later git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2867 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e1c4992680
commit
c5e8669ec0
12 changed files with 97 additions and 622 deletions
|
@ -76,7 +76,7 @@ void BlogMsgItem::updateItemStatic()
|
|||
for(i = 0; i < total; i++)
|
||||
{
|
||||
/* add file */
|
||||
SubFileItem *fi = new SubFileItem("dummyHash", "dummy_File", 1283918, SFI_STATE_REMOTE, mPeerId);
|
||||
SubFileItem *fi = new SubFileItem("dummyHash", "dummy_File", "", 1283918, SFI_STATE_REMOTE, mPeerId);
|
||||
mFileItems.push_back(fi);
|
||||
|
||||
QLayout *layout = expandFrame->layout();
|
||||
|
|
|
@ -113,8 +113,8 @@ void ChanMsgItem::updateItemStatic()
|
|||
for(it = cmi.files.begin(); it != cmi.files.end(); it++)
|
||||
{
|
||||
/* add file */
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->size,
|
||||
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size,
|
||||
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, mChanId);
|
||||
mFileItems.push_back(fi);
|
||||
|
||||
QLayout *layout = expandFrame->layout();
|
||||
|
|
|
@ -129,7 +129,7 @@ void MsgItem::updateItemStatic()
|
|||
for(it = mi.files.begin(); it != mi.files.end(); it++)
|
||||
{
|
||||
/* add file */
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->size, SFI_STATE_REMOTE, mi.srcId);
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size, SFI_STATE_REMOTE, mi.srcId);
|
||||
mFileItems.push_back(fi);
|
||||
|
||||
QLayout *layout = expandFrame->layout();
|
||||
|
|
|
@ -65,9 +65,10 @@
|
|||
const uint32_t SFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */
|
||||
|
||||
/** Constructor */
|
||||
SubFileItem::SubFileItem(std::string hash, std::string name, uint64_t size,
|
||||
SubFileItem::SubFileItem(std::string hash, std::string name, std::string path, uint64_t size,
|
||||
uint32_t flags, std::string srcId)
|
||||
:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId)
|
||||
:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId),
|
||||
mPath(path)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
|
@ -77,10 +78,6 @@ SubFileItem::SubFileItem(std::string hash, std::string name, uint64_t size,
|
|||
mMode = flags & SFI_MASK_STATE;
|
||||
mType = flags & SFI_MASK_TYPE;
|
||||
|
||||
if (mMode == SFI_STATE_EXTRA)
|
||||
{
|
||||
mMode = SFI_STATE_ERROR;
|
||||
}
|
||||
/**** Enable ****
|
||||
*****/
|
||||
|
||||
|
@ -94,25 +91,6 @@ SubFileItem::SubFileItem(std::string hash, std::string name, uint64_t size,
|
|||
Setup();
|
||||
}
|
||||
|
||||
/** Constructor */
|
||||
SubFileItem::SubFileItem(std::string path)
|
||||
:QWidget(NULL), mPath(path), mFileSize(0)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
|
||||
mMode = SFI_STATE_EXTRA;
|
||||
mType = SFI_TYPE_ATTACH;
|
||||
|
||||
/* ask for Files to hash/prepare it for us */
|
||||
if ((!rsFiles) || (!rsFiles->ExtraFileHash(path, SFI_DEFAULT_PERIOD, 0)))
|
||||
{
|
||||
mMode = SFI_STATE_ERROR;
|
||||
}
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
|
||||
void SubFileItem::Setup()
|
||||
{
|
||||
|
@ -581,12 +559,33 @@ void SubFileItem::cancel()
|
|||
|
||||
void SubFileItem::play()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "SubFileItem::play() :" << mPath;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
FileInfo info;
|
||||
uint32_t flags = RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE;
|
||||
|
||||
//openFile(mPath);
|
||||
|
||||
if (!rsFiles->FileDetails( mFileHash, flags, info))
|
||||
return;
|
||||
|
||||
if (done()) {
|
||||
|
||||
/* open file with a suitable application */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(info.path.c_str());
|
||||
if (qinfo.exists()) {
|
||||
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
||||
std::cerr << "openTransfer(): can't open file " << info.path << std::endl;
|
||||
}
|
||||
}else{
|
||||
QMessageBox::information(this, tr("Play File"),
|
||||
tr("File %1 does not exist at location.").arg(info.path.c_str()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/* rise a message box for incompleted download file */
|
||||
QMessageBox::information(this, tr("Play File"),
|
||||
tr("File %1 is not completed.").arg(info.fname.c_str()));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -41,14 +41,21 @@ const uint32_t SFI_STATE_UPLOAD = 0x0006;
|
|||
const uint32_t SFI_TYPE_CHANNEL = 0x0010;
|
||||
const uint32_t SFI_TYPE_ATTACH = 0x0020;
|
||||
|
||||
|
||||
//! This create a gui widget that allows users to access files shared by user
|
||||
/*!
|
||||
* Widget that allows user to share files with a visual attachment interface
|
||||
* Note: extra files (files not already shared/hashed in rs) need to
|
||||
* be hashed by the clients of this class or else objects of this class will
|
||||
* have reduced functionality
|
||||
*/
|
||||
class SubFileItem : public QWidget, private Ui::SubFileItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
SubFileItem(std::string localpath);
|
||||
SubFileItem(std::string hash, std::string name, uint64_t size,
|
||||
SubFileItem(std::string hash, std::string name, std::string path, uint64_t size,
|
||||
uint32_t flags, std::string srcId);
|
||||
|
||||
/** Default Destructor */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue