void FileSharingWidget::stopDownloading()
	{
		assert(isState(State::PlainFile_Downloading) ||
			   isState(State::ImageFile_Downloading));

		if (isState(State::PlainFile_Downloading))
		{
			setState(State::PlainFile_MetainfoLoaded);
			connectFileDownloadSignals(false);
		}

        if (isState(State::ImageFile_Downloading))
        {
            setState(State::ImageFile_MetainfoLoaded);
            connectImageDownloadedSignal(false);
        }

		Ui::GetDispatcher()->abortSharedFileDownloading(
			ContactUin_,
			FsInfo_->GetUri(),
			getCurrentProcessId()
		);

		resetCurrentProcessId();

		BytesTransferred_ = 0;
        Ui::GetDispatcher()->post_stats_to_core(core::stats::stats_event_names::filesharing_download_cancel);
	}
    bool FileSharingWidget::retryRequestLater()
    {
        if (!isState(State::PlainFile_Initial) &&
            !isState(State::ImageFile_Initial) &&
            !isState(State::ImageFile_MetainfoLoaded))
        {
            return false;
        }

        assert(RetryCount_ >= 0);
        assert(RetryCount_ <= RETRY_MAX);
        if (RetryCount_ >= RETRY_MAX)
        {
            return false;
        }

        ++RetryCount_;

        QTimer::singleShot(
            RETRY_INTERVAL_MS,
            Qt::VeryCoarseTimer,
            this,
            &FileSharingWidget::retryRequest
        );

        return true;
    }
	bool FileSharingWidget::isDataTransferProgressVisible() const
	{
		return isState(State::PlainFile_Downloading) ||
			   isState(State::PlainFile_Uploading) ||
			   isState(State::ImageFile_Downloading) ||
			   isState(State::ImageFile_Uploading);
	}
	void FileSharingWidget::setFileInfo(qint64 seq, QString rawUri, QString miniPreviewUri, QString fullPreviewUri, QString downloadUri, QString filename, qint64 size, bool)
	{
		assert(!rawUri.isEmpty());
		assert(!filename.isEmpty());
		assert(!downloadUri.isEmpty());
		assert(size > 0);

		if (!isCurrentProcessId(seq))
		{
			return;
		}

        const auto isImageFileInitial = isState(State::ImageFile_Initial);
        const auto isPlainFileInitial = isState(State::PlainFile_Initial);

        assert(isImageFileInitial || isPlainFileInitial);

        resetCurrentProcessId();

        const auto isPreviewNotReady = (
            isImageFileInitial &&
            (miniPreviewUri.isEmpty() || fullPreviewUri.isEmpty())
        );
        if (isPreviewNotReady)
        {
            retryRequestLater();
            return;
        }

        connectMetainfoSignal(false);

        RetryCount_ = 0;

		Metainfo_.Filename_ = filename;
		Metainfo_.FileSize_ = size;
		Metainfo_.MiniPreviewUri_ = miniPreviewUri;
		Metainfo_.FullPreviewUri_ = fullPreviewUri;
		Metainfo_.DownloadUri_ = downloadUri;

		if (isImageFileInitial)
		{
			setState(State::ImageFile_MetainfoLoaded);
			requestPreview();
		}
		else
		{
			setState(State::PlainFile_CheckingLocalCopy);
			checkLocalCopyExistence();
		}

        invalidateSizes();
		update();
	}
	const QRect& FileSharingWidget::getControlButtonRect() const
	{
		if (isState(State::PlainFile_MetainfoLoaded) ||
			isState(State::PlainFile_Downloading) ||
			isState(State::PlainFile_Downloaded) ||
			isState(State::PlainFile_Uploading) ||
			isState(State::PlainFile_Uploaded))
		{
			return getControlButtonPlainRect();
		}

		return getControlButtonPreviewRect();
	}
	void FileSharingWidget::requestMetainfo()
	{
		assert(FsInfo_);
		assert(isState(State::PlainFile_Initial) || isState(State::ImageFile_Initial));

		const auto procId = Ui::GetDispatcher()->downloadSharedFile(
			ContactUin_,
			FsInfo_->GetUri(),
            Ui::get_gui_settings()->get_value<QString>(settings_download_directory, Utils::DefaultDownloadsPath()),
            QString(),
			core::file_sharing_function::download_meta);

        setCurrentProcessId(procId);
	}
	void FileSharingWidget::startDownloadingFullImage()
	{
		assert(isState(State::ImageFile_Downloading));

        // start animation

		startDataTransferAnimation();

        // reset existing process

        connectMetainfoSignal(false);

		connectImageDownloadedSignal(false);

        resetCurrentProcessId();

        // start image downloading

        connectFileDownloadSignals(true);

		const auto procId = Ui::GetDispatcher()->downloadSharedFile(
			ContactUin_,
			FsInfo_->GetUri(),
            Ui::get_gui_settings()->get_value<QString>(
                settings_download_directory,
                Utils::DefaultDownloadsPath()
            ),
            QString(),
			core::file_sharing_function::download_file
        );

        setCurrentProcessId(procId);
        Ui::GetDispatcher()->post_stats_to_core(core::stats::stats_event_names::filesharing_download_file);
	}
	void FileSharingWidget::imageDownloaded(qint64 seq, QString uri, QPixmap preview, QString)
	{
		assert(!uri.isEmpty());

		if (!isCurrentProcessId(seq))
		{
			return;
		}

		const auto isDownloading = isState(State::ImageFile_Downloading);
		if (!isDownloading)
		{
            assert(!"unexpected widget state");
			return;
		}

		assert(!Metainfo_.DownloadUri_.isEmpty());
		assert(uri == Metainfo_.DownloadUri_);

        resetCurrentProcessId();

		if (preview.isNull())
		{
            connectImageDownloadedSignal(false);
			return;
		}

		Preview_.FullImg_ = preview;
		setState(State::ImageFile_Downloaded);
		connectImageDownloadedSignal(false);

        invalidateSizes();
		update();
	}
Beispiel #9
0
LLFace*	LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep)
{
	
	LLFace *face;
	{
		LLFastTimer t(FTM_ALLOCATE_FACE);
		face = new LLFace(this, mVObjp);
	}

	if (!face) LL_ERRS() << "Allocating new Face: " << mFaces.size() << LL_ENDL;
	
	if (face)
	{
		mFaces.push_back(face);

		if (poolp)
		{
			face->setPool(poolp, texturep);
		}

		if (isState(UNLIT))
		{
			face->setState(LLFace::FULLBRIGHT);
		}
	}
	return face;
}
BOOL LLDrawable::updateMove()
{
	if (isDead())
	{
		llwarns << "Update move on dead drawable!" << llendl;
		return TRUE;
	}
	
	if (mVObjp.isNull())
	{
		return FALSE;
	}
	
	makeActive();
	
	BOOL done;

	if (isState(MOVE_UNDAMPED))
	{
		done = updateMoveUndamped();
	}
	else
	{
		done = updateMoveDamped();
	}
	return done;
}
    void FileSharingWidget::retryRequest()
    {
        if (isState(State::PlainFile_Initial) ||
            isState(State::ImageFile_Initial))
        {
            requestMetainfo();
            return;
        }

        if (isState(State::ImageFile_MetainfoLoaded))
        {
            requestPreview();
            return;
        }

        assert(!"unexpected widget state");
    }
Beispiel #12
0
void LLDrawable::makeActive()
{		
#if !LL_RELEASE_FOR_DOWNLOAD
	if (mVObjp.notNull())
	{
		U32 pcode = mVObjp->getPCode();
		if (pcode == LLViewerObject::LL_VO_WATER ||
			pcode == LLViewerObject::LL_VO_VOID_WATER ||
			pcode == LLViewerObject::LL_VO_SURFACE_PATCH ||
			pcode == LLViewerObject::LL_VO_PART_GROUP ||
			pcode == LLViewerObject::LL_VO_HUD_PART_GROUP ||
#if ENABLE_CLASSIC_CLOUDS
			pcode == LLViewerObject::LL_VO_CLOUDS ||
#endif
			pcode == LLViewerObject::LL_VO_GROUND ||
			pcode == LLViewerObject::LL_VO_SKY)
		{
			LL_ERRS() << "Static viewer object has active drawable!" << LL_ENDL;
		}
	}
#endif

	if (!isState(ACTIVE)) // && mGeneration > 0)
	{
		setState(ACTIVE);
		
		//parent must be made active first
		if (!isRoot() && !mParent->isActive())
		{
			mParent->makeActive();
			//NOTE: linked set will now NEVER become static
			mParent->setState(LLDrawable::ACTIVE_CHILD);
		}

		//all child objects must also be active
		llassert_always(mVObjp);
		
		LLViewerObject::const_child_list_t& child_list = mVObjp->getChildren();
		for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
			 iter != child_list.end(); iter++)
		{
			LLViewerObject* child = *iter;
			LLDrawable* drawable = child->mDrawable;
			if (drawable)
			{
				drawable->makeActive();
			}
		}

		if (mVObjp->getPCode() == LL_PCODE_VOLUME)
		{
			gPipeline.markRebuild(this, LLDrawable::REBUILD_VOLUME, TRUE);
		}
		updatePartition();
	}

	llassert(isAvatar() || isRoot() || mParent->isActive());
}
void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
{
	if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
	{
		llwarns << "Attempted to update distance for non-world camera." << llendl;
		return;
	}

	//switch LOD with the spatial group to avoid artifacts
	//LLSpatialGroup* sg = getSpatialGroup();

	LLVector3 pos;

	//if (!sg || sg->changeLOD())
	{
		LLVOVolume* volume = getVOVolume();
		if (volume)
		{
			if (getSpatialGroup())
			{
				pos.set(getPositionGroup().getF32ptr());
			}
			else
			{
				pos = getPositionAgent();
			}
			
			if (isState(LLDrawable::HAS_ALPHA))
			{
				for (S32 i = 0; i < getNumFaces(); i++)
				{
					LLFace* facep = getFace(i);
					if (force_update || facep->getPoolType() == LLDrawPool::POOL_ALPHA)
					{
						LLVector4a box;
						box.setSub(facep->mExtents[1], facep->mExtents[0]);
						box.mul(0.25f);
						LLVector3 v = (facep->mCenterLocal-camera.getOrigin());
						const LLVector3& at = camera.getAtAxis();
						for (U32 j = 0; j < 3; j++)
						{
							v.mV[j] -= box[j] * at.mV[j];
						}
						facep->mDistance = v * camera.getAtAxis();
					}
				}
			}	
		}
		else
		{
			pos = LLVector3(getPositionGroup().getF32ptr());
		}

		pos -= camera.getOrigin();	
		mDistanceWRTCamera = llround(pos.magVec(), 0.01f);
		mVObjp->updateLOD();
	}
}
	const QRect& FileSharingWidget::getControlButtonPreviewRect() const
	{
		assert(isState(State::ImageFile_Downloading) ||
			   isState(State::ImageFile_Uploading));

		if (Private_.ControlButtonPreviewRect_.isEmpty())
		{
			const auto &btn = downloadCancelButton();

			auto buttonRect = btn.GetRect();

			buttonRect.moveCenter(getPreviewScaledRect().center());

			Private_.ControlButtonPreviewRect_ = buttonRect;
		}

		return Private_.ControlButtonPreviewRect_;
	}
Beispiel #15
0
void AbstractThread::setPriority( const int32_t priority )
{
    TLockMutex l( m_mutex );
    
    if ( isState( ThreadState_Running ) )
    {
        setThreadPriority( m_thread, priority );
    }
}
Beispiel #16
0
void AbstractThread::requestStop()
{
    TLockMutex l( m_mutex );    

    if ( isState( ThreadState_Running ) )
    {
        setState( ThreadState_StopRequested );
    }
}
	bool FileSharingWidget::isBlockElement() const
	{
		return (isState(State::PlainFile_Initial) ||
				isState(State::PlainFile_MetainfoLoaded) ||
				isState(State::PlainFile_CheckingLocalCopy) ||
				isState(State::PlainFile_Downloading) ||
				isState(State::PlainFile_Downloaded) ||
				isState(State::PlainFile_Uploading) ||
				isState(State::PlainFile_Uploaded) ||
				isState(State::PlainFile_UploadError));
	}
Beispiel #18
0
 void StateStorage::setClientInfo( State state, const ClientInfoRefPtr c )
 {
   //Check to make sure this is a valid state.
   if(! isState(state) )
   {
     addState(state);
   }
   //Update the state's info.
   stateInfos[state] = c;
 }
	void FileSharingWidget::stopUploading()
	{
		assert(isState(State::PlainFile_Uploading) ||
			   isState(State::ImageFile_Uploading));
		assert(!FsInfo_->GetUploadingProcessId().isEmpty());
		assert(FsInfo_->HasLocalPath());

		setState(State::Deleted);

		Ui::GetDispatcher()->abortSharedFileUploading(
			ContactUin_,
			FsInfo_->GetLocalPath(),
			FsInfo_->GetUploadingProcessId()
		);

		emit removeMe();

		BytesTransferred_ = 0;
        Ui::GetDispatcher()->post_stats_to_core(core::stats::stats_event_names::filesharing_cancel);
	}
Beispiel #20
0
void LLDrawable::makeStatic(BOOL warning_enabled)
{
	if (isState(ACTIVE) && 
		!isState(ACTIVE_CHILD) && 
		!mVObjp->isAttachment() && 
		!mVObjp->isFlexible())
	{
		clearState(ACTIVE | ANIMATED_CHILD);

		//drawable became static with active parent, not acceptable
		llassert(mParent.isNull() || !mParent->isActive() || !warning_enabled);
		
		LLViewerObject::const_child_list_t& child_list = mVObjp->getChildren();
		for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
			 iter != child_list.end(); iter++)
		{
			LLViewerObject* child = *iter;
			LLDrawable* child_drawable = child->mDrawable;
			if (child_drawable)
			{
				if (child_drawable->getParent() != this)
				{
					LL_WARNS() << "Child drawable has unknown parent." << LL_ENDL;
				}
				child_drawable->makeStatic(warning_enabled);
			}
		}
		
		if (mVObjp->getPCode() == LL_PCODE_VOLUME)
		{
			gPipeline.markRebuild(this, LLDrawable::REBUILD_VOLUME, TRUE);
		}		
		
		if (mSpatialBridge)
		{
			mSpatialBridge->markDead();
			setSpatialBridge(NULL);
		}
		updatePartition();
	}
}
Beispiel #21
0
const LLColor4& LLFace::getRenderColor() const
{
	if (isState(USE_FACE_COLOR))
	{
		  return mFaceColor; // Face Color
	}
	else
	{
		const LLTextureEntry* tep = getTextureEntry();
		return (tep ? tep->getColor() : LLColor4::white);
	}
}
	bool FileSharingWidget::isControlButtonVisible() const
	{
		return isState(State::PlainFile_MetainfoLoaded) ||
			   isState(State::PlainFile_Downloading) ||
			   isState(State::PlainFile_Downloaded) ||
			   isState(State::PlainFile_Uploading) ||
			   isState(State::PlainFile_Uploaded) ||
			   isState(State::ImageFile_Downloading) ||
			   isState(State::ImageFile_Uploading);
	}
	void FileSharingWidget::fileDownloaded(qint64 seq, QString rawUri, QString localPath)
	{
		assert(!rawUri.isEmpty());
		assert(QFile::exists(localPath));

		if (!isCurrentProcessId(seq))
		{
			return;
		}

		DownloadedFileLocalPath_ = localPath;

        const auto isPlainFileDownloading = isState(State::PlainFile_Downloading);
		if (isPlainFileDownloading)
		{
			setState(State::PlainFile_Downloaded);
		}

		const auto isImageDownloading = isState(State::ImageFile_Downloading);
		if (isImageDownloading)
		{
            setState(State::ImageFile_Downloaded);
		}

		stopDataTransferAnimation();

        invalidateSizes();
		update();

        if (CopyFile_)
        {
            CopyFile_ = false;
            copyFile();
        }

        if (SaveAs_)
        {
            SaveAs_ = false;
        }
	}
	void FileSharingWidget::renderControlButton(QPainter &p)
	{
		assert(isControlButtonVisible());

		if (isState(State::PlainFile_Downloading) ||
			isState(State::PlainFile_Uploading) ||
			isState(State::ImageFile_Downloading) ||
			isState(State::ImageFile_Uploading))
		{
			downloadCancelButton().Draw(p, getControlButtonRect());
			return;
		}

		if (isState(State::PlainFile_Downloaded) ||
			isState(State::PlainFile_Uploaded))
		{
			if (!FileTypeIcon_)
			{
				FileTypeIcon_ = GetIconByFilename(Metainfo_.Filename_);
			}

			FileTypeIcon_->Draw(p, getControlButtonRect());

			return;
		}

		downloadButton().Draw(p, getControlButtonRect());
	}
Beispiel #25
0
bool AbstractThread::join( const uint32_t timeout )
{
    bool result = false;
    
    TLockUnique l( m_mutex );
    
    if ( !isState( ThreadState_New ) )
    {             
        while( !isState( ThreadState_Stopped ) )
        {           
            m_condition.wait( l );
        }                
        
        if( m_thread.joinable() )
        {
            m_thread.join();
            result = true;
        }
    }
        
    return result;
}
	void FileSharingWidget::mouseMoveEvent(QMouseEvent *event)
	{
        const auto mousePos = event->pos();

		if (isControlButtonVisible())
		{
			if (isOverControlButton(mousePos) &&
				!isState(State::PlainFile_Downloaded) &&
				!isState(State::PlainFile_Uploaded) &&
				!isState(State::ImageFile_Uploaded))
			{
				setCursor(Qt::PointingHandCursor);
				return;
			}
		}

		if (isOpenDownloadsDirButtonVisible())
		{
			if (isOverOpenDownloadsDirButton(mousePos))
			{
				setCursor(Qt::PointingHandCursor);
				return;
			}
		}

        const auto isClickable = (
            canStartImageDownloading(mousePos) ||
            isState(State::ImageFile_Downloaded) ||
            isState(State::ImageFile_Uploaded)
        );
		if (isClickable)
		{
			setCursor(Qt::PointingHandCursor);
			return;
		}

		setCursor(Qt::ArrowCursor);
		event->ignore();
	}
	void FileSharingWidget::checkLocalCopyExistence()
	{
		assert(isState(State::PlainFile_CheckingLocalCopy));

		connectFileDownloadSignals(true);

		const auto procId = (int)Ui::GetDispatcher()->downloadSharedFile(
			ContactUin_,
			FsInfo_->GetUri(),
            Ui::get_gui_settings()->get_value<QString>(settings_download_directory, Utils::DefaultDownloadsPath()), QString(),
			core::file_sharing_function::check_local_copy_exists);

        setCurrentProcessId(procId);
	}
    bool FileSharingWidget::canUnload() const
	{
		return (!isState(State::PlainFile_Initial) &&
				!isState(State::PlainFile_CheckingLocalCopy) &&
				!isState(State::PlainFile_Downloading) &&
				!isState(State::PlainFile_Uploading) &&
				!isState(State::ImageFile_Initial) &&
				!isState(State::ImageFile_Downloading));
	}
Beispiel #29
0
void RF24Mesh::handle_UpdateWeightMessage(RF24NetworkHeader& header)
{

  read(header,0,0);
  IF_SERIAL_DEBUG(printf_P(PSTR("%lu: handle_UpdateWeightMessage (%s) \n\r"),rTable.getMillis(),header.toString()));

  if(isState(JOINED))
  {
	  // If this message is from ourselves or the base, don't bother adding it to the active nodes.
		if (header.from_node != rTable.getShortestRouteNode().ip
				&& header.prev_node != getMyIP())
	  {
		  IF_SERIAL_DEBUG(printf_P(PSTR("%lu: handle_U farkli node kaydet ve cevap ver\n\r"),rTable.getMillis()));
		  bool shortenedPath = rTable.addNearNode(header.source_data);
		  if(shortenedPath)
		  {
			  send_UpdateWeight();
		  }
	  }
	  else //msg came from my child about me; omit the msg
	  {

	  }
	  rTable.printTable();
  }
  else if(isState(NJOINED))
  {
	  IF_SERIAL_DEBUG(printf_P(PSTR("%lu: handle_U farkli node kaydet ve cevap ver\n\r"),rTable.getMillis()));
	  bool shortenedPath = rTable.addNearNode(header.source_data);
	  if(shortenedPath)
	  {
		  setState(JOINED);
		  last_join_time = millis();
		  send_UpdateWeight();
	  }
  }
}
	bool FileSharingWidget::isFilenameAndSizeVisible() const
	{
		return isState(State::PlainFile_MetainfoLoaded) ||
			   isState(State::PlainFile_Downloading) ||
			   isState(State::PlainFile_Downloaded) ||
			   isState(State::PlainFile_Uploading) ||
			   isState(State::PlainFile_Uploaded) ||
			   isState(State::PlainFile_CheckingLocalCopy);
	}