Esempio n. 1
0
bool VDVideoDisplayMinidriverOpenGL::Update(UpdateMode mode) {
	if (!mGL.IsInited())
		return false;

	if (!mSource.pixmap.data)
		return false;

	if (HDC hdc = GetDC(mhwndOGL)) {
		if (mGL.Begin(hdc)) {
			VDASSERT(mGL.glGetError() == GL_NO_ERROR);

			if (mSource.bInterlaced) {
				uint32 fieldmode = (mode & kModeFieldMask);

				if (fieldmode == kModeAllFields || fieldmode == kModeEvenField) {
					VDPixmap evenFieldSrc(mSource.pixmap);

					evenFieldSrc.h = (evenFieldSrc.h+1) >> 1;
					evenFieldSrc.pitch += evenFieldSrc.pitch;

					Upload(evenFieldSrc, mTexPattern[0]);
				}
				if (fieldmode == kModeAllFields || fieldmode == kModeOddField) {
					VDPixmap oddFieldSrc(mSource.pixmap);

					oddFieldSrc.data = (char *)oddFieldSrc.data + oddFieldSrc.pitch;
					oddFieldSrc.h = (oddFieldSrc.h+1) >> 1;
					oddFieldSrc.pitch += oddFieldSrc.pitch;

					Upload(oddFieldSrc, mTexPattern[1]);
				}
Esempio n. 2
0
void ITexture::Apply()
{
	if (!mSamplerName.IsEmpty())
	{
		auto pass = RenderingContext::Instance().ProgramRenderPass();
		if (pass != nullptr)
		{
			ShaderUniform* sampler = pass->FindUniform(mSamplerName);
			if (sampler != nullptr)
			{
				sampler->Invalidate();
				sampler->Set((int)mSamplerState->TextureUnit() - (int)GraphicsTextureUnits::Texture0);
			}
			else
			{
				//Log::LogErrorFormat("Cannot find sampler by name:{}",mSamplerName.c_str());
			}
		}

	}

	RenderStateMachine::Instance().Push(mSamplerState);
	RenderStateMachine::Instance().Push(mPixelStoreState);

	Upload();
}
NS_IMETHODIMP
WriteStumbleOnThread::Run()
{
  MOZ_ASSERT(!NS_IsMainThread());

  bool b = sIsAlreadyRunning.exchange(true);
  if (b) {
    return NS_OK;
  }

  STUMBLER_DBG("In WriteStumbleOnThread\n");

  UploadFileStatus status = GetUploadFileStatus();

  if (UploadFileStatus::NoFile != status) {
    if (UploadFileStatus::ExistsAndReadyToUpload == status) {
      Upload();
    }
  } else {
    Partition partition = GetWritePosition();
    if (partition == Partition::Unknown) {
      STUMBLER_ERR("GetWritePosition failed, skip once");
    } else {
      WriteJSON(partition);
    }
  }

  sIsAlreadyRunning = false;
  return NS_OK;
}
std::string CallHprose::UploadHprose( std::string strHproseRpc, std::string strFilePath )
{
	std::string strJson = Upload(strHproseRpc, strFilePath);
	DataInterfaceReturn oReturn;
	oReturn.FromJson(strJson);
	return oReturn.file;
}
Esempio n. 5
0
	void Plugin::handlePollFinished ()
	{
		IsPolling_ = false;
		while (!UploadQueue_.isEmpty ())
		{
			const auto& item = UploadQueue_.takeFirst ();
			Upload (item.LocalPath_, item.OrigLocalPath_, item.To_, item.StorageID_);
		}

		auto watcher = dynamic_cast<QFutureWatcher<USBDevInfos_t>*> (sender ());
		watcher->deleteLater ();

		const auto& infos = watcher->result ();
		if (!infos.isEmpty ())
		{
			Infos_ = infos;
			emit availableDevicesChanged ();
		}

		if (FirstPoll_)
		{
			Subscribe2Devs ();
			FirstPoll_ = false;
		}

		QTimer::singleShot (120000,
				this,
				SLOT (pollDevices ()));
	}
Esempio n. 6
0
  //
  // HandleEvent
  //
  // Pass any events to the registered handler
  //
  U32 Mission::HandleEvent(Event &e)
  {
    if (e.type == IFace::EventID())
    {
      switch (e.subType)
      {
        case IFace::NOTIFY:
        {
          // Do specific handling
          switch (e.iface.p1)
          {
            case MissionMsg::Done:
              Upload();
              break;

            default : 
              ICWindow::HandleEvent(e);
              break;
          }

          return (TRUE);
        }
      }
    }

    return (ICWindow::HandleEvent(e));  
  }
Esempio n. 7
0
void DiGLTextureDrv::UnlockLevel(uint32 level, uint32 surface)
{
    if (mCurrentLockFlag != LOCK_READ_ONLY)
    {
        DiBox lockbox(0, 0, mBuffer->GetWidth(), mBuffer->GetHeight());
        Upload(*mBuffer, lockbox, level, surface);
    }
    DeallocateBuffer();
}
Esempio n. 8
0
/*******************************************************************************
**函    数: SearchFace
**功    能: 寻找及确认面值
**参    数: void
**返    回: 匹配面(1-6)      0xFF   未匹配
*******************************************************************************/
u8 Cube6_SearchFace(void)
{
    u8  i;
    s16 CurTmp[3];  
    static u8 KeepTimes=0;
    static u8 OldFace=0xff;
    static u8 EnsureFlag;
    
    if(1 == gGetMPUFlag) return 0xff;     //震动保护
    
    MPU6050_ReadAcce(CurTmp);             //读取加速度 
    
    for(i=0;i<6;i++)
    {
        if((CurTmp[0]>=UpFaceTab[i][0]-ACCE_OFFSRT)&&(CurTmp[0] < UpFaceTab[i][0]+ACCE_OFFSRT))
        {   
            if( (CurTmp[1] >=UpFaceTab[i][1]-ACCE_OFFSRT)&& \
                (CurTmp[1] < UpFaceTab[i][1]+ACCE_OFFSRT)&& \
                (CurTmp[2] >=UpFaceTab[i][2]-ACCE_OFFSRT)&& \
                (CurTmp[2] < UpFaceTab[i][2]+ACCE_OFFSRT))
            {
                if(i == OldFace)        //判断数据是否保持
                {
                    if((KeepTimes++ >=5)&&(EnsureFlag==0))
                    {
                        KeepTimes  = 0;
                        EnsureFlag = 1;
                        gEnsureFace = i+1;
                        if(OldEnsureFace != gEnsureFace)
                        {
                            StandbyCountReset();                            
                            OldEnsureFace = gEnsureFace; 
                            gGetMPUFlag   = 1;                             
                            PropEventFifo(1, 0x01,SRCEVENT,gEnsureFace);
                            ShakeMotor_Start();
                            Thread_Login(ONCEDELAY, 0 ,50, &ShakeMotor_Stop);
                            Upload();
                            #if  CUBE6_SUPPORT_PRINTF
                            printf("Face OK is %d \r\n",gEnsureFace);
                            #endif                           
                        }                                                           
                    }
                }
                else { 
                    KeepTimes=0;
                    EnsureFlag=0;
                }
                OldFace = i;
                return i;
            }       
        }
    }
    /*The face is not match...*/
    KeepTimes = 0;
    OldFace   = 0xff;
    return 0xff;    
}
Esempio n. 9
0
	void Render(ExampleClock& clock)
	{
		positions.clear();
		ages.clear();

		// update the emitters and get the particle data
		for(auto i=emitters.begin(), e=emitters.end(); i!=e; ++i)
		{
			i->Update(clock);
			i->Upload(positions, ages);
		}
		assert(positions.size() == ages.size());

		// make a camera matrix
		auto cameraMatrix = CamMatrixf::Orbiting(
			Vec3f(),
			38.0 - SineWave(clock.Now().Seconds() / 6.0) * 17.0,
			FullCircles(clock.Now().Seconds() * 0.1),
			Degrees(SineWave(clock.Now().Seconds() / 20.0) * 60)
		);

		std::vector<float> depths(positions.size());
		std::vector<GLuint> indices(positions.size());
		// calculate the depths of the particles
		for(GLuint i=0, n=positions.size(); i!=n; ++i)
		{
			depths[i] = (cameraMatrix * Vec4f(positions[i], 1.0)).z();
			indices[i] = i;
		}

		// sort the indices by the depths
		std::sort(
			indices.begin(),
			indices.end(),
			[&depths](GLuint i, GLuint j)
			{
				return depths[i] < depths[j];
			}
		);

		// upload the particle positions
		pos_buf.Bind(Buffer::Target::Array);
		Buffer::Data(Buffer::Target::Array, positions, BufferUsage::DynamicDraw);
		// upload the particle ages
		age_buf.Bind(Buffer::Target::Array);
		Buffer::Data(Buffer::Target::Array, ages, BufferUsage::DynamicDraw);

		gl.Clear().ColorBuffer().DepthBuffer();
		camera_matrix.Set(cameraMatrix);
		// use the indices to draw the particles
		gl.DrawElements(
			PrimitiveType::Points,
			indices.size(),
			indices.data()
		);
	}
NS_IMETHODIMP
UploadStumbleRunnable::Run()
{
  MOZ_ASSERT(NS_IsMainThread());
  nsresult rv = Upload();
  if (NS_FAILED(rv)) {
    WriteStumbleOnThread::UploadEnded(false);
  }
  return NS_OK;
}
Esempio n. 11
0
// Update function
void Model::Update(double delta, double now)
{
    // If we need to upload the mesh data, do so now
    if(!uploaded)
    {
        Upload();
    }
    
    // Other shit
}
Esempio n. 12
0
wxCurlThreadError wxCurlUploadThread::Upload(const wxString &url, wxInputStream *in)
{
    wxCurlThreadError ret;

    if ((ret=SetURL(url)) != wxCTE_NO_ERROR)
        return ret;
    if ((ret=SetInputStream(in)) != wxCTE_NO_ERROR)
        return ret;

    return Upload();
}
 //
 // Activate
 //
 Bool Options::Activate()
 {
   if (ICWindow::Activate())
   {
     Upload();
     return (TRUE);
   }
   else
   {
     return (FALSE);
   }
 }
Esempio n. 14
0
bool
BufferTextureHost::MaybeUpload(nsIntRegion *aRegion)
{
  if (mFirstSource && mFirstSource->GetUpdateSerial() == mUpdateSerial) {
    return true;
  }
  if (!Upload(aRegion)) {
    return false;
  }
  mFirstSource->SetUpdateSerial(mUpdateSerial);
  return true;
}
Esempio n. 15
0
 virtual void Update(const InputState& inputs, Uint32 timestamp)
 {
     if (timestamp > lastUpdate + animationDelay)
     {
         lastUpdate = timestamp;
         tile++;
     }
     
     if (vbo->Changed())
     {
         Upload();
         vbo->ChangeCommitted();
     }
 }
Esempio n. 16
0
void Main()
{
	TextureAsset::Register(L"noise", L"Texture/noise.png");
	//設定の読み込み
	LoadConfig();
	//タイトル
	String Title(L"高専の敷き詰め理論ⅠB");
	Point TitlePos(10, 0);
	//ウィンドウスタイルの設定
	Window::SetStyle(WindowStyle::NonFrame);
	Window::Resize(960, 540);
	//フォントの用意
	Font titlefont(30);
	Texture Back(L"Texture/BlackBord.png");
	Rect font_size = titlefont.region(Title);
	//ボタンの用意
	Button Download(download, 20, 100, L"・ダウンロード");
	Button SelectFile(selectfile, 20, 170, L"・ファイルを選択");
	Button ReAnswer(reanswer, 20, 240, L"・再度問題を解く");
	Button Upload(upload, 20, 350, L"・アップロード");
	//バグ除け
	Gout << L"準備完了\n";

	while (System::Update()){
		//ボタンのアップデート
		if (Download.end && SelectFile.end && Upload.end && ReAnswer.end){
			Download.Update();
			SelectFile.Update();
			Upload.Update();
			ReAnswer.Update();
		}

		//描画
		Back.draw();
		titlefont(Title).draw(TitlePos, Palette::White);
		TextureAsset(L"noise").map(font_size.w, font_size.h).draw(TitlePos);

		Download.Draw();
		SelectFile.Draw();
		ReAnswer.Draw();
		Upload.Draw();

		Gout.Draw();
		DD.Draw();
	}
}
Esempio n. 17
0
bool
BufferTextureHost::MaybeUpload(nsIntRegion *aRegion)
{
  if (mFirstSource && mFirstSource->GetUpdateSerial() == mUpdateSerial) {
    return true;
  }
  if (!Upload(aRegion)) {
    return false;
  }

  // We no longer have an invalid region.
  mNeedsFullUpdate = false;
  mMaybeUpdatedRegion.SetEmpty();

  // If upload returns true we know mFirstSource is not null
  mFirstSource->SetUpdateSerial(mUpdateSerial);
  return true;
}
Esempio n. 18
0
    VboScene(
        std::shared_ptr<ShaderInterface> shader, 
        std::shared_ptr<VboInterface> vbo, 
        std::shared_ptr<SDL_Surface> texSurface,
        Uint32 animationDelay = 200)
            : vbo(vbo),
            shader(shader),
            texSurface(texSurface),
            texturePresent(texSurface.get() != nullptr),
            tile(0),
            animationDelay(animationDelay),
            lastUpdate(0),
            transparency(1.0f),
            x(0),
            y(0)
    {
        glGenBuffers(1, &buffer);
        Upload();

    }
Esempio n. 19
0
std::string CallHprose::Upload( std::string strHproseRpc, std::string strFilePath )
{
	m_strFileId = "";
	DataInterfaceReturn oReturn;

	CDownUploadDataFileObject dataFileObject;
	dataFileObject.m_strHproseRpc = strHproseRpc;
	dataFileObject.m_strFilePath = strFilePath;
	Upload(&dataFileObject);

	if (dataFileObject.m_strFileId.empty())
	{
		oReturn.error = "1";
		oReturn.msg = ZTools::FormatString("error msg: %s", dataFileObject.m_strMsg.c_str());
	}
	else
	{
		oReturn.error = "0";
		oReturn.file = m_strFileId;
	}

	return oReturn.ToJson();
}
Esempio n. 20
0
std::string CallHprose::UploadUseCache(CDownUploadDataFileObject* pFileObject, bool bMove/* = false*/)
{
	if (CDownUploadFileCacheFinder::ReadUploadCache(pFileObject))
	{
		if (!pFileObject->m_strFileId.empty())
		{
			ZTools::WriteZToolsFormatLog("上传使用本地缓存中的记录");

			//pFileObject->m_strFileId = m_strFileId;
			pFileObject->m_nFileSizeUploaded = pFileObject->m_nFileSize;
			return pFileObject->m_strFileId;
		}
	}	

	std::string strFileId = Upload(pFileObject);

	if (!strFileId.empty())
	{
		CDownUploadFileCacheFinder::WriteUploadCache(pFileObject);
		CDownUploadFileCacheFinder::WriteDownloadCacheInUpload(pFileObject, bMove);
	}

	return strFileId;
}
/*******************************************************************
函 数 名:	Msg_Execute
功能说明: 	消息执行
参	  数: 	data:	要执行的数据内容
			len;	数据长度
返 回 值:	TRUE(重复)/FALSE(不重复)
*******************************************************************/
MsgResult_t Msg_Execute(CMDPara_t *para)
{
    MsgResult_t result = NO_CMD;
    const AttrExe_st *pAttrExe = UnitTab[para->unit].attrExe;
    u8 ExeAttrNum = 0u;
    u8 ackLen = 0;

    if (para->unit < UnitCnt_Get())	//指令单元没有越界	2014.01.08 Unarty add 防止访问越界
    {
        do  //遍历属性列表
        {
            if (pAttrExe->cmd == para->cmd)	//属性号匹配OK
            {
                /*写操作*/
                if (WRITEWITHACK == para->msgType
                        || WRITENACK == para->msgType
                        || WRITESUC  == para->msgType
                        || WRITEFAIL == para->msgType
                   )
                {
                    if (pAttrExe->pSet_Attr != NULL)
                    {
                        if (!gUnitData[para->unit].able)	//单元被禁用
                        {
                            result = UNIT_DISABLE;
                            Upload(para->unit);
                        }
                        else
                        {
#if (DALAY_EXECUTE_EN > 0u)
                            //消息过滤
                            DlyMsgFilterProcess((UnitPara_t*)&para->unit,RELATE_MSG_DEL);		//
#endif
                            result =  pAttrExe->pSet_Attr((UnitPara_t*)&para->unit);
                            if (result == OWN_RETURN_PARA) //如果写入结里带返回参数
                            {
                                if (pAttrExe->cmd > 0xCF)
                                {
                                    result = COMPLETE;
                                }
                                ackLen = para->len;
                                memmove((&para->len) + 2, (&para->len) + 1, ackLen);  //V1.8 add
                            }
                        }
                    }
                    else
                    {
                        result = NO_WRITE;	//没有写权限
                    }
                }
                /*读操作*/
                else if (READWITHACK == para->msgType
                         || READSUC == para->msgType
                         || READFAIL == para->msgType
                        )
                {
                    if (pAttrExe->pGet_Attr != NULL)
                    {
                        result = pAttrExe->pGet_Attr((UnitPara_t*)&para->unit, &ackLen, ((&para->len) + 2));//((&para->len) + 1));V1.8 Chang
                    }
                    else
                    {
                        result = NO_READ;	//没有读权限
                    }
                }
                else
                {
                    result = MSG_TYPE_ERR;	//消息类型错误
                }
                break;
            }
        }
        while (((++ExeAttrNum) < UnitTab[para->unit].ExeAttrNum())   //2016.01.29 jay modify
                &&((++pAttrExe)->cmd < 0x0100));
        /*while((pAttrExe->cmd < (++pAttrExe)->cmd)		//2014.12.28 Unarty Add
        		&& (pAttrExe->cmd < 0x0100));*/
    }

    para->len = ackLen + 1;
    *((&para->len)+1) = result;		//V1.8 ADD

    return result;
}
Esempio n. 22
0
bool CUploader::UploadFile(const std::string& FileName, const std::string displayFileName) {
	FileUploadTask task(FileName, displayFileName);
	return Upload(&task);
}
Esempio n. 23
0
File: menu.c Progetto: ftnapps/FTNd
void DoMenu(int Type)
{
    int	    Strlen, i, x;
    char    *sPrompt, *sPromptBak, *temp;

    sPrompt    = calloc(81, sizeof(char));
    sPromptBak = calloc(81, sizeof(char));
    temp       = calloc(81, sizeof(char));

    TimeCheck();

    switch(Type) {
	case 0: /* Display Prompt Line Only */
		break;

	case 1:
		/* Goto another menu */
		strncpy(Menus[MenuLevel], menus.OptionalData, 14);
		break;

	case 2:
		/* Gosub another menu */
		if (MenuLevel < 49) {
		    MenuLevel++;
		    strncpy(Menus[MenuLevel], menus.OptionalData, 14);
		} else
		    Syslog('?', "More than 50 menu levels");
		break;

	case 3:
		/* Return from gosub */
		if (MenuLevel > 0) 
		    MenuLevel--;
		break;

	case 4:
		/* Return to top menu */
		MenuLevel = 0;
		break;

	case 5:
		/* Display .a?? file with controlcodes */
		DisplayFile(menus.OptionalData);
		break;

	case 6:
		/* Show menu prompt */
		Strlen = strlen(menus.OptionalData);
		for (x = 0; x < Strlen; x++) {
		    if (menus.OptionalData[x] == '~') {
			strcat(sPrompt, sUserTimeleft);
		    } else {
			snprintf(temp, 81, "%c", menus.OptionalData[x]);
			strcat(sPrompt, temp);
		    }
		}
		strcpy(sPromptBak, sPrompt);
		strcpy(sPrompt, "");
		Strlen = strlen(sPromptBak);
		for (x = 0; x < Strlen; x++) {
		    if (*(sPromptBak + x) == '@')
			strcat(sPrompt, sAreaDesc);
		    else if (*(sPromptBak + x) == '^')
			strcat(sPrompt, sMsgAreaDesc);
		    else if (*(sPromptBak + x) == '#')
			snprintf(sPrompt, 81, "%s%s", sPrompt, (char *) GetLocalHM()); 
		    else {
			snprintf(temp, 81, "%c", *(sPromptBak + x));
			strcat(sPrompt, temp);
		    }
		}
		if (le_int(menus.ForeGnd) || le_int(menus.BackGnd))
		    pout(le_int(menus.ForeGnd), le_int(menus.BackGnd), sPrompt);
		else
		    pout(WHITE, BLACK, sPrompt);
		break;

	case 7:
		/* Run external program */
		if (strlen(menus.DoorName) && !menus.HideDoor) {
		    memset(temp, 0, sizeof(temp));
		    strcpy(temp, menus.DoorName);
		    ExtDoor(menus.OptionalData, menus.NoDoorsys, menus.Y2Kdoorsys, menus.Comport, 
			menus.NoSuid, menus.NoPrompt, menus.SingleUser, temp);
		} else {
		    ExtDoor(menus.OptionalData, menus.NoDoorsys, menus.Y2Kdoorsys, menus.Comport,
			menus.NoSuid, menus.NoPrompt, menus.SingleUser, NULL);
		}
		break;

	case 8:
		/* Show product information */
		cr();
		break;

	case 9:
		/* display todays callers */
		LastCallers(menus.OptionalData);
		break;

	case 10:
		/* display userlist */
		UserList(menus.OptionalData);
		break;

	case 11:
		/* display time statistics */
		TimeStats();
		break;

	case 12:
		/* page sysop for chat */
		Page_Sysop(menus.OptionalData);
		break;

	case 13:
		/* terminate call */
		free(sPrompt);
		free(sPromptBak);
		free(temp);
		Good_Bye(FTNERR_OK);
		break;

	case 14:
		/* make a log entry */
		LogEntry(menus.OptionalData);
		break;

	case 15:
		/* print text to screen */
		if (exitinfo.Security.level >= le_int(menus.MenuSecurity.level)) {
		    for (i = 0; i < strlen(menus.OptionalData); i++)
			if (*(menus.OptionalData + i) == '@')
			    *(menus.OptionalData + i) = '\n';
		    snprintf(temp, 81, "%s\r\n", menus.OptionalData);
		    PUTSTR(temp);
		}
		break;

	case 16:
		/* who's currently online */
		WhosOn(menus.OptionalData);
		Pause();
		break;

	case 17:
		/* comment to sysop */
		SysopComment((char *)"Comment to Sysop");
		break;

	case 18:
		/* send on-line message */
		SendOnlineMsg(menus.OptionalData);
		break;
		
	case 19:
		/* display Textfile with more */
		MoreFile(menus.OptionalData);
		break;

	case 20:
		/* display a?? file with controlcode and wait for enter */
		DisplayFileEnter(menus.OptionalData);
 		break;

	case 21:
		/* display menuline only */
		break;

	case 22:
		/* Chat with any user */
		Chat(NULL, NULL);
		break;

	case 101:
		FileArea_List(menus.OptionalData);
		break;

	case 102:
		File_List();
		break;

	case 103:
		ViewFile(NULL);
		break;

	case 104:
		Download();
		break;

	case 105:
		File_RawDir(menus.OptionalData);
		break;

	case 106:
		KeywordScan();
		break;

	case 107:
		FilenameScan();
		break;

	case 108:
		NewfileScan(TRUE);
		break;

	case 109:
		Upload();
		break;

	case 110:
		EditTaglist();
		break;

	case 111: /* View file in homedir */
		break;

	case 112:
		DownloadDirect(menus.OptionalData, TRUE);
		break;

	case 113:
		Copy_Home();
		break;

	case 114:
		List_Home();
		break;

	case 115:
		Delete_Home();
		break;

	/* 116 Unpack file in homedir */

	/* 117 Pack files in homedir */

	case 118:
		Download_Home();
		break;

	case 119:
		Upload_Home();
		break;

	case 201:
		MsgArea_List(menus.OptionalData);
		break;

	case 202:
		Post_Msg(); 
		break;

	case 203:
		Read_Msgs();
		break;

	case 204:
		CheckMail();
		break;

	case 205:
		QuickScan_Msgs();
		break;

	case 206:
		Delete_Msg();
		break;

	case 207:
		MailStatus();
		break;

	case 208:
		OLR_TagArea();
		break;

	case 209:
		OLR_UntagArea();
		break;

	case 210:
		OLR_ViewTags();
		break;

	case 211:
		OLR_RestrictDate();
		break;

	case 212:
		OLR_Upload();
		break;

	case 213:
		OLR_DownBW();
		break;

	case 214:
		OLR_DownQWK();
		break;

	case 215:
		OLR_DownASCII();
		break;

	case 216:
		Read_Email();
		break;

	case 217:
		Write_Email();
		break;

	case 218:
		Trash_Email();
		break;

	case 219:
		Choose_Mailbox(menus.OptionalData);
		break;

	case 220:
		QuickScan_Email();
		break;

	case 221:
		DisplayRules();
		break;

	case 301:
		Chg_Protocol();
		break;

	case 302:
		Chg_Password();
		break;

	case 303:
		Chg_Location();
		break;

	case 305:
		Chg_VoicePhone();
		break;

	case 306:
		Chg_DataPhone();
		break;

	case 307:
		Chg_News();
		break;

	case 309:
		Chg_DOB();
		break;

	case 310:
		Chg_Language(FALSE);
		break;

	case 311:
		Chg_Hotkeys();
		break;

	case 312:
		Chg_Handle();
		break;

	case 313:
		Chg_MailCheck();
		break;

	case 314:
		Chg_Disturb();
		break;

	case 315:
		Chg_FileCheck();
		break;

	case 316:
		Chg_FsMsged();
		break;

	case 317:
		Chg_FsMsgedKeys();
		break;

	case 318:
		Chg_Address();
		break;

	case 319:
		signature();
		break;

	case 320:
		Chg_OLR_ExtInfo();
		break;

	case 321:
		Chg_Charset();
		break;

	case 322:
		Chg_Archiver();
		break;

	case 401:
		Oneliner_Add();
		break;

	case 402:
		Oneliner_List();
		break;

	case 403:
		Oneliner_Show();
		break;

	case 404:
		Oneliner_Delete();
		break;

	case 405:
		Oneliner_Print();
		break;

	default:
		Enter(1);
		pout(WHITE, BLACK, (char *) Language(339));
		Enter(2);
		Syslog('?', "Option: %s -> Unknown Menu Type: %d on %s", menus.MenuKey, Type, Menus[MenuLevel]); 
		Pause();
	}

	free(sPrompt);
	free(sPromptBak);
	free(temp);
}
/*******************************************************************************
**函    数: KeyInit
**功    能: 初始化
**参    数: unitID      --单元号
**返    回: void
*******************************************************************************/
void KeyInit(u8 unitID)
{
    u8 i;
	Battery_Init();
    Init_OLED();
    _74HC595_Init();
    ShowLED_OpenAll();
    
    if(1 == Battery_GetPercent(&gPowerPercent))
    {
        if(gPowerPercent <= 8)   //电量小于8%时自动提示用户充电,3s以后休眠
        {
            OLED_ShowPicAt(36,2,56,32,PicPower);
            Thread_Login(ONCEDELAY, 0,3000,&Standby_Mode);
            for(;;);       
        }
    }
    
    EEPROM_Read(ADDR_PASSWORD, 4, &gPassword[0]);
    if((gPassword[0]>6)||(gPassword[1]>6)||(gPassword[2]>6)||(gPassword[3]>6))
    {
        gPassword[0] = 0;
        gPassword[1] = 0;
        gPassword[2] = 0;
        gPassword[3] = 0;
    }
    if((gPassword[0]==0)||(gPassword[1]==0)||(gPassword[2]==0)||(gPassword[3]==0))
    {
        gPswFlag = 0;       //无密码
    }
    else gPswFlag = 1;      //有密码
        
    Thread_Login(FOREVER, 0, 5 , &Key_Handle);           //5ms 按键
    Thread_Login(FOREVER, 0, 100, &LowPower_CheckTime);   //100ms*100 = 10s  睡眠 
    Thread_Login(FOREVER, 0, 200 ,&Battery_Show);    
    
    Get_CurrentKeyState(&gKeyPrevState);
    if((gKeyPrevState.KeyValue > MAX_TOUCH_KEY)||(!gKeyPrevState.KeyValue))
    {
        gKeyPrevState.KeyValue = first_key;
    }
	if((gKeyPrevState.KeyType > KEY_LONG)||(KEY_NONE == gKeyPrevState.KeyType))
	{
		gKeyPrevState.KeyType = KEY_SHORT;
	}
	gKeyCh[gKeyPrevState.KeyValue].Status = gKeyPrevState.KeyType;
	for(i = 1;i < MAX_TOUCH_KEY;i++)
	{
		if(gKeyPrevState.KeyStatusVal[i] > 1)
		{
			gKeyPrevState.KeyStatusVal[i] = SW_OFF;
		}
		gKeyStatus[i].Status = gKeyPrevState.KeyStatusVal[i];
	}
	switch(gKeyPrevState.KeyType)
	{
		case KEY_SHORT:
		{
			if(SW_ON == gKeyStatus[gKeyPrevState.KeyValue].Status)
			{
				OLED_ShowHalfPicAt(4,PicTab[gKeyPrevState.KeyValue]);
			}
			else
			{
				OLED_ShowHalfPicAt(4,PicTab[gKeyPrevState.KeyValue + 32]);
			}
		}break;
		case KEY_LONG:
		{
			OLED_ShowHalfPicAt(4,PicTab[gKeyPrevState.KeyValue + 16]);
		}break;
		default:break;
	}
    Battery_Show_State();
    
    Upload(1);
}
Esempio n. 25
0
void InventoryWindow::CreateActions()
{
    /*
        itemMenu_ = new QMenu(this);
        fileTransferMenu_ = new QMenu(this);
        connect(actionMenu_, SIGNAL(aboutToShow()), this, SLOT(UpdateActions()));
    */
    // File transfer actions
    InventoryAction  *actionUpload= new InventoryAction(tr("&Upload"), treeView_);
    actionUpload->setObjectName("Upload");
    actionUpload->setStatusTip(tr("Upload file to your inventory"));
    connect(actionUpload, SIGNAL(triggered()), this, SLOT(Upload()));
    treeView_->addAction(actionUpload);

    InventoryAction *actionDownload = new InventoryAction(tr("&Download"), treeView_);
    actionDownload->setObjectName("Download");
    actionDownload->setStatusTip(tr("Download assets to your hard drive"));
    connect(actionDownload, SIGNAL(triggered()), this, SLOT(Download()));
    treeView_->addAction(actionDownload);

    // Add separator
    InventoryAction *actionSeparator = new InventoryAction(treeView_);
    actionSeparator->setSeparator(true);
    treeView_->addAction(actionSeparator);

    // Inventory item actions.
    InventoryAction  *actionDelete = new InventoryAction(tr("&Delete"), treeView_);
    actionDelete->setObjectName("Delete");
    //actionDelete_->setShortcuts(QKeySequence::Delete);
    actionDelete->setStatusTip(tr("Delete this item"));
    connect(actionDelete, SIGNAL(triggered()), this, SLOT(DeleteItem()));
    treeView_->addAction(actionDelete);

    InventoryAction *actionRename = new InventoryAction(tr("&Rename"), treeView_);
    actionRename->setObjectName("Rename");
    //actionRename_->setShortcuts();
    actionRename->setStatusTip(tr("Rename this item"));
    connect(actionRename, SIGNAL(triggered()), this, SLOT(RenameItem()));
    treeView_->addAction(actionRename);

    /*
        InventoryAction  *actionCut_ = new InventoryAction(tr("&Cut"), treeView_);
        actionDelete_->setShortcuts(QKeySequence::Cut);
        actionDelete_->setStatusTip(tr("Cut this item"));
        connect(actionCut_, SIGNAL(triggered()), this, SLOT(Test()));
        treeView_->addAction(actionCut_);

        InventoryAction  *actionPaste_ = new InventoryAction(tr("&Paste"), treeView_);
        actionDelete_->setShortcuts(QKeySequence::Paste);
        actionDelete_->setStatusTip(tr("Paste this item"));
        connect(actionPaste_, SIGNAL(triggered()), this, SLOT(Test()));
        treeView_->addAction(actionPaste_);
    */

    InventoryAction  *actionNewFolder = new InventoryAction(tr("&New folder"), treeView_);
    actionNewFolder->setObjectName("NewFolder");
    //actionDelete_->setShortcuts(QKeySequence::Delete);
    actionNewFolder->setStatusTip(tr("Create new folder"));
    connect(actionNewFolder, SIGNAL(triggered()), this, SLOT(AddFolder()));
    treeView_->addAction(actionNewFolder);

    InventoryAction *actionOpen = new InventoryAction(tr("&Open"), treeView_);
    actionOpen->setObjectName("Open");
    //actionDelete_->setShortcuts(QKeySequence::Delete);
    actionOpen->setStatusTip(tr("Open this item"));
    connect(actionOpen, SIGNAL(triggered()), this, SLOT(OpenItem()));
    treeView_->addAction(actionOpen);

    InventoryAction  *actionProperties= new InventoryAction(tr("&Properties"), treeView_);
    actionProperties->setObjectName("Properties");
    //actionProperties_->setShortcuts(QKeySequence::Delete);
    actionProperties->setStatusTip(tr("View item properties"));
    connect(actionProperties, SIGNAL(triggered()), this, SLOT(OpenItemProperties()));
    treeView_->addAction(actionProperties);

    InventoryAction *actionCopyAssetReference = new InventoryAction(tr("&Copy asset reference"), treeView_);
    actionCopyAssetReference->setObjectName("CopyAssetReference");
    //actionDelete_->setShortcuts(QKeySequence::Delete);
    actionCopyAssetReference->setStatusTip(tr("Copies asset reference to clipboard"));
    connect(actionCopyAssetReference, SIGNAL(triggered()), this, SLOT(CopyAssetReference()));
    treeView_->addAction(actionCopyAssetReference);
}
Esempio n. 26
0
void DiGLTextureDrv::CopyFromMemory(const DiPixelBox &srcBox, const DiBox &dst, uint32 level, uint32 surface /*= 0*/)
{
    AllocateBuffer();
    Upload(srcBox, dst, level, surface);
    DeallocateBuffer();
}
Esempio n. 27
0
bool CUserPageBuilder::Build(CWholePage* pWholePage)
{
	// introducing the players - these will point to the XML objects required
	// to construct a user page
	CPageUI			Interface(m_InputContext);
	CUser*			pViewer = NULL;
	CUser			Owner(m_InputContext);
	CGuideEntry		Masthead(m_InputContext);
	CForum			PageForum(m_InputContext);
	CForum			Journal(m_InputContext);
	CPostList		RecentPosts(m_InputContext);
	CArticleList	RecentArticles(m_InputContext);
	CArticleList	RecentApprovals(m_InputContext);
	CCommentsList	RecentComments(m_InputContext);
	CArticleSubscriptionList	SubscribedUsersArticles(m_InputContext);
	
	CTDVString	sSecretKey;
	int			iSecretKey = 0;
	int			iUserID = 0;		// the user ID in the URL
	bool		bRegistering = false;
	bool		bSuccess = true;	// our success flag

	// get the user ID from the URL => zero if not present
	// TODO: something appropriate if no ID provided	
	iUserID = m_InputContext.GetParamInt("UserID");
	// now get the secret key if there is one
	// we may need to process it so get it as a string
	if (m_InputContext.GetParamString("Key", sSecretKey))
	{
		// if the secret key start with "3D" we must strip this off
		// - it is caused by a mime encoding problem, 3D is the ascii hex for =
		if (sSecretKey.Find("3D") == 0)
		{
			sSecretKey =  sSecretKey.Mid(2);
		}
		iSecretKey = atoi(sSecretKey);
		if (iSecretKey > 0)
		{
			// if there is a secret key then it is a registration attempt
			bRegistering = true;
		}
	}
	// now give appropriate page depending on whether this is a registration or not
	if (bRegistering)
	{
//		CStoredProcedure* pSP = m_InputContext.CreateStoredProcedureObject();
		CTDVString sPageContent = "";
		CTDVString sPageSubject = "";
//		CTDVString sCookie;

		// check we got our SP okay
//		if (pSP == NULL)
//		{
//			bSuccess = false;
//		}
		// if so then call the activate user method, which should return us a nice
		// warm cookie if all goes well
//		if (bSuccess)
//		{
//			bSuccess = pSP->ActivateUser(iUserID, iSecretKey, &sCookie);
			// make sure cookie is not empty
//			if (sCookie.IsEmpty())
//			{
//				bSuccess = false;
//			}
//		}
		// if okay then build page with the cookie in and a message to the user
		if (bSuccess)
		{
			// we have a cookie and we are prepared to use it
			// TODO: what about the MEMORY tag?
			// TODO: put this in stylesheet? Deal with delayed refresh?
//			CTDVString sCookieXML = "<SETCOOKIE><COOKIE>" + sCookie + "</COOKIE></SETCOOKIE>";

//			sPageSubject = "Registration in process ...";
//			sPageContent << "<GUIDE><BODY>";
//			sPageContent << "<P>Thank you for registering as an official Researcher for The Hitch Hiker's ";
//			sPageContent << "Guide to the Galaxy: we do hope you enjoy contributing to the Guide.</P>";
//			sPageContent << "<P>Please wait while you are transferred to <LINK BIO=\"U" << iUserID << "\">";
//			sPageContent << "your Personal Home Page</LINK> ... or click the link if nothing happens.</P>";
//			sPageContent << "</BODY></GUIDE>";
//			pWholePage = CreateSimplePage(sPageSubject, sPageContent);
//			if (pWholePage == NULL)
//			{
//				bSuccess = false;
//			}

			if (bSuccess)
			{
				bSuccess = InitPage(pWholePage, "USERPAGE",false);
			}
			// put the cookie xml inside the H2G2 tag
//			bSuccess = pWholePage->AddInside("H2G2", sCookieXML);

//			CTDVString sUserXML = "";
//			sUserXML << "<REGISTERING-USER>";
//			sUserXML << "<USER>";
//			sUserXML << "<USERNAME></USERNAME>";
//			sUserXML << "<USERID>" << iUserID << "</USERID>";
//			sUserXML << "</USER>";
//			sUserXML << "</REGISTERING-USER>";
//			bSuccess = pWholePage->AddInside("H2G2", sUserXML);
//			bSuccess = bSuccess && pWholePage->SetPageType("REGISTER-CONFIRMATION");

		CTDVString sRedirect;
		sRedirect << "ShowTerms" << iUserID;
		sRedirect << "?key=" << sSecretKey;
		pWholePage->Redirect(sRedirect);
		}
		else
		{
			sPageSubject = "Sorry ...";
			sPageContent << "<GUIDE><BODY>";
			sPageContent << "<P>The URL you've given is wrong. Please re-check your email, or <LINK HREF=\"/Register\">click here to re-enter your email address</LINK>.</P>";
			sPageContent << "</BODY></GUIDE>";
			bSuccess = CreateSimplePage(pWholePage, sPageSubject, sPageContent);
		}
		// make sure we delete the SP if any
//		delete pSP;
//		pSP = NULL;
	}
	else
	{
		// get or create all the appropriate xml objects
		pViewer		= m_InputContext.GetCurrentUser();
		bool bGotMasthead = false; 
		bool bGotPageForum = false; 
		bool bGotJournal = false; 
		bool bGotRecentPosts = false; 
		bool bGotRecentArticles = false; 
		bool bGotRecentApprovals = false; 
		bool bGotRecentComments = false; 
		bool bGotSubscribedToUsersRecentArticles = false; 

		bool bGotOwner		= CreatePageOwner(iUserID, Owner);

		CreatePageTemplate(pWholePage);
		if (m_InputContext.IncludeUsersGuideEntryInPersonalSpace() || (m_InputContext.GetParamInt("i_uge") == 1) ||
			m_InputContext.IncludeUsersGuideEntryForumInPersonalSpace() || (m_InputContext.GetParamInt("i_ugef") == 1))
		{
			bGotMasthead = CreatePageArticle(iUserID, Owner, Masthead);

			if (m_InputContext.IncludeUsersGuideEntryForumInPersonalSpace() || (m_InputContext.GetParamInt("i_ugef") == 1))
			{
				// GuideEntry forum can not be returned if GuideEntry is not being returned.
				bGotPageForum = CreatePageForum(pViewer, Masthead, PageForum);
			}
		}

		bool bGotInterface = CreateUserInterface(pViewer, Owner, Masthead, Interface);
		
		// Only display other information if the page has a valid masthead
		if (bGotMasthead)
		{
			if (m_InputContext.IncludeJournalInPersonalSpace() || (m_InputContext.GetParamInt("i_j") == 1))
			{
				bGotJournal = CreateJournal(Owner, pViewer, Journal);
			}

			if (m_InputContext.IncludeRecentPostsInPersonalSpace() || (m_InputContext.GetParamInt("i_rp") == 1))
			{
				bGotRecentPosts = CreateRecentPosts(Owner, pViewer, RecentPosts);
			}

			if (m_InputContext.IncludeRecentCommentsInPersonalSpace() || (m_InputContext.GetParamInt("i_rc") == 1))
			{
				bGotRecentComments = CreateRecentComments(Owner, pViewer, RecentComments);
			}

			if (m_InputContext.IncludeRecentGuideEntriesInPersonalSpace() || (m_InputContext.GetParamInt("i_rge") == 1))
			{
				bGotRecentArticles = CreateRecentArticles(Owner, RecentArticles);
				bGotRecentApprovals = CreateRecentApprovedArticles(Owner, RecentApprovals);
			}

			if (m_InputContext.IncludeUploadsInPersonalSpace() || (m_InputContext.GetParamInt("i_u") == 1))
			{
				CTDVString sUploadsXML;
				CUpload Upload(m_InputContext);
				Upload.GetUploadsForUser(iUserID,sUploadsXML);
				pWholePage->AddInside("H2G2",sUploadsXML);
			}

			if (m_InputContext.IncludeRecentArticlesOfSubscribedToUsersInPersonalSpace() || (m_InputContext.GetParamInt("i_rasu") == 1))
			{
				bGotSubscribedToUsersRecentArticles = CreateSubscribedToUsersRecentArticles(Owner, m_InputContext.GetSiteID(), SubscribedUsersArticles); 
			}
		}

		// See if the user wants to swap to this site and change their masthead and journal (if it exists)
/*
	This feature is now redundant. There's no concept of a homesite.
		if (m_InputContext.ParamExists("homesite"))
		{
			if (pViewer == NULL)
			{
				// error: Not registered - ignore request
			}
			else if (!bGotOwner)
			{
				// error - no actual owner, ignore request
			}
			else if (pViewer->GetIsEditor())
			{
				int iCurrentSiteID = m_InputContext.GetSiteID();
				int iThisSite = iCurrentSiteID;
				if (bGotMasthead)
				{
					iCurrentSiteID = Masthead.GetSiteID();
				}
				if ( iThisSite != iCurrentSiteID && m_InputContext.CanUserMoveToSite(iCurrentSiteID, iThisSite))
				{
					CStoredProcedure SP;
					m_InputContext.InitialiseStoredProcedureObject(&SP);
					if (bGotMasthead)
					{
						SP.MoveArticleToSite(Masthead.GetH2G2ID(), m_InputContext.GetSiteID());
						//delete pMasthead;
						Masthead.Destroy();
						bGotMasthead = CreatePageArticle(iUserID, Owner, Masthead);
					}
					int iJournal;
					Owner.GetJournal(&iJournal);
					if (iJournal > 0)
					{
						SP.MoveForumToSite(iJournal, m_InputContext.GetSiteID());
					}

					int iPrivateForum;
					if (Owner.GetPrivateForum(&iPrivateForum))
					{
						SP.MoveForumToSite(iPrivateForum, m_InputContext.GetSiteID());
					}
					pWholePage->AddInside("H2G2", "<SITEMOVED RESULT='success'/>");
				}
			}
		}
*/
		// check that all the *required* objects have been created successfully
		// note that pViewer can be NULL if an unregistered viewer
		// pOwner can be NULL if we are serving a default page because this user ID
		// does not exist
		// bGotJournal can be false if the user doesn't exist, or has no journal
		// bGotRecentPosts can be false if the user doesn't exist
		// pRecentArticles can be NULL if the user doesn't exist
		// pRecentApprovals can be NULL if the user doesn't exist
		// bGotPageForum can be false if there is no masthead, or if it has no forum yet
		// pMasthead could be NULL if the user has not created one yet
		if (pWholePage->IsEmpty() || bGotInterface == false)
		{
			bSuccess = false;
		}
		// now add all the various subcomponents into the whole page xml
		// add owner of page
		if (bSuccess)
		{
			// if we have a page owner then put their details in, otherwise make
			// up a pretend user from the ID we were given
			if (bGotOwner)
			{
				bSuccess = pWholePage->AddInside("PAGE-OWNER", &Owner);
			}
			else
			{
				CTDVString sPretendUserXML = "";
				sPretendUserXML << "<USER><USERID>" << iUserID << "</USERID>";
				sPretendUserXML << "<USERNAME>Researcher " << iUserID << "</USERNAME></USER>";
				bSuccess = pWholePage->AddInside("PAGE-OWNER", sPretendUserXML);
			}
		}
		// there should always be an interface but check anyway
		if (bSuccess && bGotInterface)
		{
			bSuccess = pWholePage->AddInside("H2G2", &Interface);
		}
		if (bSuccess && m_InputContext.ParamExists("clip"))
		{
			CTDVString sSubject;
			if (bGotOwner)
			{
				Owner.GetUsername(sSubject);
			}
			else
			{
				sSubject << "U" << iUserID;
			}

			bool bPrivate = m_InputContext.GetParamInt("private") > 0;
			CLink Link(m_InputContext);
			if ( Link.ClipPageToUserPage("userpage", iUserID, sSubject, NULL, pViewer, bPrivate) )
				pWholePage->AddInside("H2G2", &Link);
		}
		// if masthead NULL stylesheet should do the default response
		if (bSuccess && bGotMasthead && (m_InputContext.IncludeUsersGuideEntryInPersonalSpace() || (m_InputContext.GetParamInt("i_uge") == 1)))
		{
			bSuccess = pWholePage->AddInside("H2G2", &Masthead);
		}
		// add page forum if there is one => this is the forum associated with
		// the guide enty that is the masthead for this user
		if (bSuccess && bGotPageForum && (m_InputContext.IncludeUsersGuideEntryForumInPersonalSpace() || (m_InputContext.GetParamInt("i_ugef") == 1)))
		{
			bSuccess = pWholePage->AddInside("H2G2", &PageForum);
		}
		// add journal if it exists
		if (bSuccess && bGotJournal)
		{
			bSuccess = pWholePage->AddInside("JOURNAL", &Journal);
		}
		// add recent posts if they exist, this may add an empty
		// POST-LIST tag if the user exists but has never posted
		if (bSuccess && bGotRecentPosts)
		{
			bSuccess = pWholePage->AddInside("RECENT-POSTS", &RecentPosts);
		}
		// add recent articles if they exist, this may add an empty
		// ARTICLES-LIST tag if the user exists but has never written a guide entry
		if (bSuccess && bGotRecentArticles)
		{
			bSuccess = pWholePage->AddInside("RECENT-ENTRIES", &RecentArticles);
			// add the user XML for the owner too
			if (bGotOwner)
			{
				bSuccess = bSuccess && pWholePage->AddInside("RECENT-ENTRIES", &Owner);
			}
		}
		// add recent articles if they exist, this may add an empty
		// ARTICLES-LIST tag if the user exists but has never had an entry approved
		if (bSuccess && bGotRecentApprovals)
		{
			bSuccess = pWholePage->AddInside("RECENT-APPROVALS", &RecentApprovals);
			// add the user XML for the owner too
			if (bGotOwner)
			{
				bSuccess = bSuccess && pWholePage->AddInside("RECENT-APPROVALS", &Owner);
			}
		}
		// add recent comments if they exist, this may add an empty
		// COMMENTS-LIST tag if the user exists but has never posted
		if (bSuccess && bGotRecentComments)
		{
			bSuccess = pWholePage->AddInside("RECENT-COMMENTS", &RecentComments);
		}

		if (bSuccess && bGotSubscribedToUsersRecentArticles)
		{
			bSuccess = pWholePage->AddInside("RECENT-SUBSCRIBEDARTICLES", &SubscribedUsersArticles);
		}

		CTDVString sSiteXML;
		m_InputContext.GetSiteListAsXML(&sSiteXML);
		bSuccess = bSuccess && pWholePage->AddInside("H2G2", sSiteXML);

		if (bGotMasthead && (m_InputContext.IncludeWatchInfoInPersonalSpace() || (m_InputContext.GetParamInt("i_wi") == 1)))
		{
			CWatchList WatchList(m_InputContext);
			bSuccess = bSuccess && WatchList.Initialise(iUserID);
			bSuccess = bSuccess && pWholePage->AddInside("H2G2",&WatchList);
			int iSiteID = m_InputContext.GetSiteID();
			bSuccess = bSuccess && WatchList.WatchingUsers(iUserID, iSiteID);
			bSuccess = bSuccess && pWholePage->AddInside("H2G2",&WatchList);
		}

		CWhosOnlineObject Online(m_InputContext);
		bSuccess = bSuccess && Online.Initialise(NULL, 1, true);
		bSuccess = bSuccess && pWholePage->AddInside("H2G2", &Online);

		if (bGotMasthead && (m_InputContext.IncludeClubsInPersonalSpace() || (m_InputContext.GetParamInt("i_c") == 1)))
		{
			if (pViewer != NULL && pViewer->GetUserID() == iUserID) 
			{
				CClub Club(m_InputContext);
				Club.GetUserActionList(iUserID, 0, 20);
				pWholePage->AddInside("H2G2", &Club);
			}

			// Now add all the clubs the user belongs to
			CCurrentClubs Clubs(m_InputContext);
			if (bSuccess && Clubs.CreateList(iUserID,true))
			{
				bSuccess = pWholePage->AddInside("H2G2",&Clubs);
			}
		}
		
		if (bGotMasthead && bSuccess && (m_InputContext.IncludePrivateForumsInPersonalSpace() || (m_InputContext.GetParamInt("i_pf") == 1)))
		{
			pWholePage->AddInside("H2G2", "<PRIVATEFORUM/>");
			CForum Forum(m_InputContext);
			int iPrivateForum = 0;
			if (bGotOwner)
			{
				Owner.GetPrivateForum(&iPrivateForum);
			}
			Forum.GetThreadList(pViewer, iPrivateForum, 10,0);
			pWholePage->AddInside("PRIVATEFORUM", &Forum);

			// Now check to see if the user has alerts set for their private forum
			if (bGotOwner)
			{
				CEmailAlertList Alert(m_InputContext);
				Alert.GetUserEMailAlertSubscriptionForForumAndThreads(iUserID,iPrivateForum);
				pWholePage->AddInside("PRIVATEFORUM", &Alert);
			}
		}

		if (bGotMasthead && bSuccess && (m_InputContext.IncludeLinksInPersonalSpace() || (m_InputContext.GetParamInt("i_l") == 1)))
		{
			CTDVString sLinkGroup;
			m_InputContext.GetParamString("linkgroup", sLinkGroup);
			if (bGotOwner && pViewer != NULL && Owner.GetUserID() == pViewer->GetUserID()) 
			{
				ManageClippedLinks(pWholePage);
			}
			if (bGotOwner)
			{
				CLink Link(m_InputContext);
				bool bShowPrivate = (pViewer != NULL && Owner.GetUserID() == pViewer->GetUserID());
				Link.GetUserLinks(Owner.GetUserID(), sLinkGroup, bShowPrivate);
				pWholePage->AddInside("H2G2", &Link);
				Link.GetUserLinkGroups(Owner.GetUserID());
				pWholePage->AddInside("H2G2", &Link);
			}
		}

		if (bGotMasthead && m_InputContext.IncludeTaggedNodesInPersonalSpace() || (m_InputContext.GetParamInt("i_tn") == 1))
		{
			//Get the Users Crumtrail - all the nodes + ancestors the user is tagged to .
			CCategory CCat(m_InputContext);
			if ( bSuccess && CCat.GetUserCrumbTrail(Owner.GetUserID()) )
			{
				bSuccess = pWholePage->AddInside("H2G2",&CCat);
			}
		}

		if (bSuccess && bGotMasthead)
		{
			CTDVString sPostCodeXML;
			CTDVString sNoticeXML;
			if (m_InputContext.IncludeNoticeboardInPersonalSpace() || (m_InputContext.GetParamInt("i_n") == 1) ||
				m_InputContext.IncludePostcoderInPersonalSpace() || (m_InputContext.GetParamInt("i_p") == 1))
			{
				if (pViewer != NULL)
				{
					// Insert the notice board information!
					CTDVString sPostCodeToFind;
					if(pViewer->GetPostcode(sPostCodeToFind))
					{
						int iSiteID = m_InputContext.GetSiteID();
						CNotice Notice(m_InputContext);
						if (!Notice.GetLocalNoticeBoardForPostCode(sPostCodeToFind,iSiteID,sNoticeXML,sPostCodeXML))
						{
							sNoticeXML << "<NOTICEBOARD><ERROR>FailedToFindLocalNoticeBoard</ERROR></NOTICEBOARD>";
						}
					}
					else
					{
						//if the user has not entered a postcode then flag an Notice Board error
						sNoticeXML << "<NOTICEBOARD><ERROR>UserNotEnteredPostCode</ERROR></NOTICEBOARD>";
					}
				}
				else
				{
					sNoticeXML << "<NOTICEBOARD><ERROR>UserNotLoggedIn</ERROR></NOTICEBOARD>";
				}

				if (m_InputContext.IncludeNoticeboardInPersonalSpace() || (m_InputContext.GetParamInt("i_n") == 1))
				{
					bSuccess = pWholePage->AddInside("H2G2",sNoticeXML);
				}
			}

			if (m_InputContext.IncludePostcoderInPersonalSpace() || (m_InputContext.GetParamInt("i_p") == 1))
			{
				// Insert the postcoder if it's not empty
				if (bSuccess && !sPostCodeXML.IsEmpty())
				{
					bSuccess = bSuccess && pWholePage->AddInside("H2G2",sPostCodeXML);
				}
			}
		}

		if (m_InputContext.IncludeSiteOptionsInPersonalSpace() || (m_InputContext.GetParamInt("i_so") == 1))
		{
			// Return SiteOption SystemMessageOn if set. 
			if (bSuccess && m_InputContext.IsSystemMessagesOn(m_InputContext.GetSiteID()))
			{
				CTDVString sSiteOptionSystemMessageXML = "<SITEOPTION><NAME>UseSystemMessages</NAME><VALUE>1</VALUE></SITEOPTION>"; 

				bSuccess = bSuccess && pWholePage->AddInside("H2G2",sSiteOptionSystemMessageXML);
			}
		}
		
/*
		Mark Howitt 11/8/05 - Removing the civic data from the user page as it is nolonger used by any sites.
							  The only place civic data is used now is on the postcoder page.

		//include civic data
		if (bSuccess)
		{
			if ( m_InputContext.GetSiteID( ) == 16 )
			{
				CTDVString sActualPostCode;				
				bool bFoundLocalInfo = false;
				// First check to see if there is a postcode in the URL
				if (m_InputContext.ParamExists("postcode"))
				{
					// Get the postcode and use this to display the noticeboard
					if (m_InputContext.GetParamString("postcode", sActualPostCode))
					{
						//dont do any validations
						bFoundLocalInfo = true;				
					}
				}

				//next if no postcode variable is included in URL
				//or if the specified postcode value is invalid 
				//or if the specified postcode value has no entries on the db				
				if (!bFoundLocalInfo)
				{
					// No postcode given, try to get the viewing users postcode if we have one.
					if (pViewer)
					{
						if (pViewer->GetPostcode(sActualPostCode))
						{
							if ( sActualPostCode.IsEmpty( ) == false)
							{
								//dont do any validations
								bFoundLocalInfo = true;
							}
						}							
					}
					else
					{
						//try session cookie, if any 
						CTDVString sPostCodeToFind;
						CPostcoder postcoder(m_InputContext);
						CTDVString sActualPostCode = postcoder.GetPostcodeFromCookie();
						if ( !sActualPostCode.IsEmpty() )
						{
							//dont do any validations
							bFoundLocalInfo = true;
						}
					}
				}

				if ( bFoundLocalInfo )
				{
					if (!sActualPostCode.IsEmpty())
					{
						bool bHitPostcode = false;
						CPostcoder cPostcoder(m_InputContext);
						cPostcoder.MakePlaceRequest(sActualPostCode, bHitPostcode);
						if (bHitPostcode)
						{
							CTDVString sXML = "<CIVICDATA POSTCODE='";
							sXML << sActualPostCode << "'/>";
							pWholePage->AddInside("H2G2", sXML);
							bSuccess = pWholePage->AddInside("CIVICDATA",&cPostcoder);
						}
					}
				}
			}
		}
*/
	}

	return bSuccess;
}
Esempio n. 28
0
void InterpretCommand(MenuInstanceData * pMenuData, const char *pszScript) {
  char szCmd[31], szParam1[51], szParam2[51];
  char szTempScript[ 255 ];
  memset(szTempScript, 0, sizeof(szTempScript));
  strncpy(szTempScript, pszScript, 250);

  if (pszScript[0] == 0) {
    return;
  }

  char* pszScriptPointer = szTempScript;
  while (pszScriptPointer && !hangup) {
    pszScriptPointer = MenuParseLine(pszScriptPointer, szCmd, szParam1, szParam2);

    if (szCmd[0] == 0) {    // || !pszScriptPointer || !*pszScriptPointer
      break;
    }

    // -------------------------
    // Run a new menu instance

    int nCmdID = GetMenuIndex(szCmd);
    switch (nCmdID) {
    case 0: {
      // "MENU"
      // Spawn a new menu
      MenuInstanceData *pNewMenuData = static_cast<MenuInstanceData *>(malloc(sizeof(MenuInstanceData)));

      memset(pNewMenuData, 0, sizeof(MenuInstanceData));
      pNewMenuData->nFinished = 0;
      pNewMenuData->nReload = 0;

      Menus(pNewMenuData, pMenuData->szPath, szParam1);
      free(pNewMenuData);
    }
    break;
    case 1: {
      // -------------------------
      // Exit out of this instance
      // of the menu
      // -------------------------
      // "ReturnFromMenu"
      InterpretCommand(pMenuData, pMenuData->header.szExitScript);
      pMenuData->nFinished = 1;
    }
    break;
    case 2: {
      // "EditMenuSet"
      EditMenus();           // flag if we are editing this menu
      pMenuData->nFinished = 1;
      pMenuData->nReload = 1;
    }
    break;
    case 3: {
      // "DLFreeFile"
      align(szParam2);
      MenuDownload(szParam1, szParam2, true, true);
    }
    break;
    case 4: {
      // "DLFile"
      align(szParam2);
      MenuDownload(szParam1, szParam2, false, true);
    }
    break;
    case 5: {
      // "RunDoor"
      MenuRunDoorName(szParam1, false);
    }
    break;
    case 6: {
      // "RunDoorFree"
      MenuRunDoorName(szParam1, true);
    }
    break;
    case 7: {
      // "RunDoorNumber"
      int nTemp = atoi(szParam1);
      MenuRunDoorNumber(nTemp, false);
    }
    break;
    case 8: {
      // "RunDoorNumberFree"
      int nTemp = atoi(szParam1);
      MenuRunDoorNumber(nTemp, true);
    }
    break;
    case 9: {
      // "PrintFile"
      printfile(szParam1, true);
    }
    break;
    case 10: {
      // "PrintFileNA"
      printfile(szParam1, false);
    }
    break;
    case 11: {
      // "SetSubNumber"
      SetSubNumber(szParam1);
    }
    break;
    case 12: {
      // "SetDirNumber"
      SetDirNumber(szParam1);
    }
    break;
    case 13: {
      // "SetMsgConf"
      SetMsgConf(szParam1[0]);
    }
    break;
    case 14: {
      // "SetDirConf"
      SetDirConf(szParam1[0]);
    }
    break;
    case 15: {
      // "EnableConf"
      EnableConf();
    }
    break;
    case 16: {
      // "DisableConf"
      DisableConf();
    }
    break;
    case 17: {
      // "Pause"
      pausescr();
    }
    break;
    case 18: {
      // "ConfigUserMenuSet"
      ConfigUserMenuSet();
      pMenuData->nFinished = 1;
      pMenuData->nReload = 1;
    }
    break;
    case 19: {
      // "DisplayHelp"
      if (GetSession()->GetCurrentUser()->IsExpert()) {
        AMDisplayHelp(pMenuData);
      }
    }
    break;
    case 20: {
      // "SelectSub"
      ChangeSubNumber();
    }
    break;
    case 21: {
      // "SelectDir"
      ChangeDirNumber();
    }
    break;
    case 22: {
      // "SubList"
      SubList();
    }
    break;
    case 23: {
      // "UpSubConf"
      UpSubConf();
    }
    break;
    case 24: {
      // "DownSubConf"
      DownSubConf();
    }
    break;
    case 25: {
      // "UpSub"
      UpSub();
    }
    break;
    case 26: {
      // "DownSub"
      DownSub();
    }
    break;
    case 27: {
      // "ValidateUser"
      ValidateUser();
    }
    break;
    case 28: {
      // "Doors"
      Chains();
    }
    break;
    case 29: {
      // "TimeBank"
      TimeBank();
    }
    break;
    case 30: {
      // "AutoMessage"
      AutoMessage();
    }
    break;
    case 31: {
      // "BBSList"
      BBSList();
    }
    break;
    case 32: {
      // "RequestChat"
      RequestChat();
    }
    break;
    case 33: {
      // "Defaults"
      Defaults(pMenuData);
    }
    break;
    case 34: {
      // "SendEMail"
      SendEMail();
    }
    break;
    case 35: {
      // "Feedback"
      FeedBack();
    }
    break;
    case 36: {
      // "Bulletins"
      Bulletins();
    }
    break;
    case 37: {
      // "HopSub"
      HopSub();
    }
    break;
    case 38: {
      // "SystemInfo"
      SystemInfo();
    }
    break;
    case 39: {
      // "JumpSubConf"
      JumpSubConf();
    }
    break;
    case 40: {
      // "KillEMail"
      KillEMail();
    }
    break;
    case 41: {
      // "LastCallers"
      LastCallers();
    }
    break;
    case 42: {
      // "ReadEMail"
      ReadEMail();
    }
    break;
    case 43: {
      // "NewMessageScan"
      NewMessageScan();
    }
    break;
    case 44: {
      // "Goodbye"
      GoodBye();
    }
    break;
    case 45: {
      // "PostMessage"
      WWIV_PostMessage();
    }
    break;
    case 46: {
      // "NewMsgScanCurSub"
      ScanSub();
    }
    break;
    case 47: {
      // "RemovePost"
      RemovePost();
    }
    break;
    case 48: {
      // "TitleScan"
      TitleScan();
    }
    break;
    case 49: {
      // "ListUsers"
      ListUsers();
    }
    break;
    case 50: {
      // "Vote"
      Vote();
    }
    break;
    case 51: {
      // "ToggleExpert"
      ToggleExpert();
    }
    break;
    case 52: {
      // "YourInfo"
      YourInfo();
    }
    break;
    case 53: {
      // "ExpressScan"
      ExpressScan();
    }
    break;
    case 54: {
      // "WWIVVer"
      WWIVVersion();
    }
    break;
    case 55: {
      // "InstanceEdit"
      InstanceEdit();
    }
    break;
    case 56: {
      // "ConferenceEdit"
      JumpEdit();
    }
    break;
    case 57: {
      // "SubEdit"
      BoardEdit();
    }
    break;
    case 58: {
      // "ChainEdit"
      ChainEdit();
    }
    break;
    case 59: {
      // "ToggleAvailable"
      ToggleChat();
    }
    break;
    case 60: {
      // "ChangeUser"
      ChangeUser();
    }
    break;
    case 61: {
      // "CLOUT"
      CallOut();
    }
    break;
    case 62: {
      // "Debug"
      Debug();
    }
    break;
    case 63: {
      // "DirEdit"
      DirEdit();
    }
    break;
    case 65: {
      // "Edit"
      EditText();
    }
    break;
    case 66: {
      // "BulletinEdit"
      EditBulletins();
    }
    break;
    case 67: {
      // "LoadText"
      // LoadText and LoadTextFile are the same, so they are now merged.
      LoadTextFile();
    }
    break;
    case 68: {
      // "ReadAllMail"
      ReadAllMail();
    }
    break;
    case 69: {
      // "Reboot"
      RebootComputer();
    }
    break;
    case 70: {
      // "ReloadMenus"
      ReloadMenus();
    }
    break;
    case 71: {
      // "ResetUserIndex"
      ResetFiles();
    }
    break;
    case 72: {
      // "ResetQScan"
      ResetQscan();
    }
    break;
    case 73: {
      // "MemStat"
      MemoryStatus();
    }
    break;
    case 74: {
      // "PackMsgs"
      PackMessages();
    }
    break;
    case 75: {
      // "VoteEdit"
      InitVotes();
    }
    break;
    case 76: {
      // "Log"
      ReadLog();
    }
    break;
    case 77: {
      // "NetLog"
      ReadNetLog();
    }
    break;
    case 78: {
      // "Pending"
      PrintPending();
    }
    break;
    case 79: {
      // "Status"
      PrintStatus();
    }
    break;
    case 80: {
      // "TextEdit"
      TextEdit();
    }
    break;
    case 81: {
      // "UserEdit"
      UserEdit();
    }
    break;
    case 82: {
      // "VotePrint"
      VotePrint();
    }
    break;
    case 83: {
      // "YLog"
      YesturdaysLog();
    }
    break;
    case 84: {
      // "ZLog"
      ZLog();
    }
    break;
    case 85: {
      // "ViewNetDataLog"
      ViewNetDataLog();
    }
    break;
    case 86: {
      // "UploadPost"
      UploadPost();
    }
    break;
    case 87: {
      // "ClearScreen"
      GetSession()->bout.ClearScreen();
    }
    break;
    case 88: {
      // "NetListing"
      NetListing();
    }
    break;
    case 89: {
      // "WHO"
      WhoIsOnline();
    }
    break;
    case 90: {
      // /A "NewMsgsAllConfs"
      NewMsgsAllConfs();
    }
    break;
    case 91: {
      // /E "MultiEMail"
      MultiEmail();
    }
    break;
    case 92: {
      // "NewMsgScanFromHere"
      NewMsgScanFromHere();
    }
    break;
    case 93: {
      // "ValidatePosts"
      ValidateScan();
    }
    break;
    case 94: {
      // "ChatRoom"
      ChatRoom();
    }
    break;
    case 95: {
      // "DownloadPosts"
      DownloadPosts();
    }
    break;
    case 96: {
      // "DownloadFileList"
      DownloadFileList();
    }
    break;
    case 97: {
      // "ClearQScan"
      ClearQScan();
    }
    break;
    case 98: {
      // "FastGoodBye"
      FastGoodBye();
    }
    break;
    case 99: {
      // "NewFilesAllConfs"
      NewFilesAllConfs();
    }
    break;
    case 100: {
      // "ReadIDZ"
      ReadIDZ();
    }
    break;
    case 101: {
      // "UploadAllDirs"
      UploadAllDirs();
    }
    break;
    case 102: {
      // "UploadCurDir"
      UploadCurDir();
    }
    break;
    case 103: {
      // "RenameFiles"
      RenameFiles();
    }
    break;
    case 104: {
      // "MoveFiles"
      MoveFiles();
    }
    break;
    case 105: {
      // "SortDirs"
      SortDirs();
    }
    break;
    case 106: {
      // "ReverseSortDirs"
      ReverseSort();
    }
    break;
    case 107: {
      // "AllowEdit"
      AllowEdit();
    }
    break;
    case 109: {
      // "UploadFilesBBS"
      UploadFilesBBS();
    }
    break;
    case 110: {
      // "DirList"
      DirList();
    }
    break;
    case 111: {
      // "UpDirConf"
      UpDirConf();
    }
    break;
    case 112: {
      // "UpDir"
      UpDir();
    }
    break;
    case 113: {
      // "DownDirConf"
      DownDirConf();
    }
    break;
    case 114: {
      // "DownDir"
      DownDir();
    }
    break;
    case 115: {
      // "ListUsersDL"
      ListUsersDL();
    }
    break;
    case 116: {
      // "PrintDSZLog"
      PrintDSZLog();
    }
    break;
    case 117: {
      // "PrintDevices"
      PrintDevices();
    }
    break;
    case 118: {
      // "ViewArchive"
      ViewArchive();
    }
    break;
    case 119: {
      // "BatchMenu"
      BatchMenu();
    }
    break;
    case 120: {
      // "Download"
      Download();
    }
    break;
    case 121: {
      // "TempExtract"
      TempExtract();
    }
    break;
    case 122: {
      // "FindDescription"
      FindDescription();
    }
    break;
    case 123: {
      // "ArchiveMenu"
      TemporaryStuff();
    }
    break;
    case 124: {
      // "HopDir"
      HopDir();
    }
    break;
    case 125: {
      // "JumpDirConf"
      JumpDirConf();
    }
    break;
    case 126: {
      // "ListFiles"
      ListFiles();
    }
    break;
    case 127: {
      // "NewFileScan"
      NewFileScan();
    }
    break;
    case 128: {
      // "SetNewFileScanDate"
      SetNewFileScanDate();
    }
    break;
    case 129: {
      // "RemoveFiles"
      RemoveFiles();
    }
    break;
    case 130: {
      // "SearchAllFiles"
      SearchAllFiles();
    }
    break;
    case 131: {
      // "XferDefaults"
      XferDefaults();
    }
    break;
    case 132: {
      // "Upload"
      Upload();
    }
    break;
    case 133: {
      // "YourInfoDL"
      YourInfoDL();
    }
    break;
    case 134: {
      // "UploadToSysop"
      UploadToSysop();
    }
    break;
    case 135: {
      // "ReadAutoMessage"
      ReadAutoMessage();
    }
    break;
    case 136: {
      // "SetNewScanMsg"
      SetNewScanMsg();
    }
    break;
    case 137: {
      // "ReadMessages"
      ReadMessages();
    }
    break;
    /*
    case 138:
    { // "RUN"
    ExecuteBasic(szParam1);
    } break;
    */
    case 139: {
      // "EventEdit"
      EventEdit();
    }
    break;
    case 140: {
      // "LoadTextFile"
      LoadTextFile();
    }
    break;
    case 141: {
      // "GuestApply"
      GuestApply();
    }
    break;
    case 142: {
      // "ConfigFileList"
      ConfigFileList();
    }
    break;
    case 143: {
      // "ListAllColors"
      ListAllColors();
    }
    break;
#ifdef QUESTIONS
    case 144: {
      // "EditQuestions"
      EditQuestions();
    }
    break;
    case 145: {
      // "Questions"
      Questions();
    }
    break;
#endif
    case 146: {
      // "RemoveNotThere"
      RemoveNotThere();
    }
    break;
    case 147: {
      // "AttachFile"
      AttachFile();
    }
    break;
    case 148: {
      // "InternetEmail"
      InternetEmail();
    }
    break;
    case 149: {
      // "UnQScan"
      UnQScan();
    }
    break;
    // ppMenuStringsIndex[150] thru ppMenuStringsIndex[153] not used.....
    case 154: {
      // "Packers"
      Packers();
    }
    break;
    case 155: {
      // Color_Config
      color_config();
    }
    break;
    //------------------------------------------------------------------
    //  ppMenuStringsIndex[156] and [157] are reserved for SDS Systems and systems
    //  that distribute modifications.  DO NOT reuse these strings for
    //  other menu options.
    //------------------------------------------------------------------
    //    case 156:
    //    { // ModAccess
    //        ModsAccess();
    //    } break;
    //    case 157:
    //    { // SDSAccess
    //        SDSAccess();
    //      } break;
    //------------------------------------------------------------------
    case 158: {
      // InitVotes
      InitVotes();
    }
    break;
    case 161: {
      // TurnMCIOn
      TurnMCIOn();
    }
    break;
    case 162: {
      // TurnMCIOff
      TurnMCIOff();
    }
    break;
    default: {
      MenuSysopLog("The following command was not recognized");
      MenuSysopLog(szCmd);
    }
    break;
    }
  }
}
Esempio n. 29
0
void CPhotoManager::Callback(IDispatch* pDisp1, IDispatch* pDisp2, DISPID id, VARIANT* pVarResult)
{
	if (!pDisp1)
		return;

	HRESULT hr = S_OK;
	if (id == DISPID_MOUSEOVER)
	{
		CComQIPtr<IHTMLElement2> spElem2(pDisp1);
		if (!spElem2)
			return;

		hr = spElem2->focus();
		
	}
	else
	if (id == DISPID_MOUSEDOWN)
	{
		CComQIPtr<IHTMLElement> spElem(pDisp1);
		if (!spElem)
			return;
		
		CComPtr<IDispatch> spDisp;
		spElem->get_document(&spDisp);
		CComQIPtr<IHTMLDocument2> spDoc(spDisp);
		if (FAILED(hr) || !spDoc)
			return;
		
		CComPtr<IHTMLWindow2> spWnd;
		HRESULT hr = spDoc->get_parentWindow(&spWnd);
		if (FAILED(hr) || !spWnd)
			return;
		
		CComPtr<IHTMLEventObj> spEventObj;
		hr = spWnd->get_event(&spEventObj);
		if (FAILED(hr) || !spEventObj)
			return;
		
		long lVal;
		spEventObj->get_button(&lVal);
		if ( lVal == 1) // 1 = left button is pressed 		
			hr = spElem->click();		
	}
	else
	if (id == DISPID_MYCLICK)
	{
		CComQIPtr<IHTMLElement> spElem(pDisp1);
		if (!spElem)
			return;

		CComQIPtr<IHTMLImgElement> spImgElem(pDisp1);
		if (!spImgElem)
			return;

		CComPtr<IDispatch> spDisp;
		hr = spElem->get_document(&spDisp);
		if (FAILED(hr) || !spDisp)
			return;

		CComQIPtr<IHTMLDocument2> spDoc(spDisp);
		if (!spDoc)
			return;

		CString strFileName;
		bool bOK = AddAPhoto((IHTMLDocument2*)spDoc, strFileName);
		if (!bOK)
			return;
		
		CComQIPtr<IMarkupServices2> spMarkup2 = spDoc;
		if (spMarkup2)
			hr = spMarkup2->BeginUndoUnit(L"Add a Photo");

		long lElemWidth = 0;
		long lElemHeight = 0;
		GetElemSize(spElem, lElemWidth, lElemHeight);
		if (!lElemWidth && !lElemHeight)
		{
			GetImgElemSize(spImgElem, lElemWidth, lElemHeight);
			SetElemSize(spElem, lElemWidth, lElemHeight);
		}

		long lImageWidth = 0;
		long lImageHeight = 0;
		CImage Image(strFileName);
		Image.GetNativeImageSize(lImageWidth, lImageHeight);

		#define SHIFT (GetAsyncKeyState(VK_SHIFT) < 0)
		if (SHIFT)
			::MessageBox(NULL, "The photo will be embedded in the email message.", g_szAppName, MB_OK);
		else
		{
			CString strURL = m_strHost + "/cgi-bin/flashalbum/cmaddaphoto.pl";

			// strFormDataPairs is a string of name/value pairs as follows "name1:value1|\nname2:value2|\n"
			CString strFormDataPairs;
			strFormDataPairs += "inputfile:~" + strFileName + "|\n";

			CUploadImages Upload(ULI_NOUPSIZE /*| ULI_LEAVETEMP | ULI_DEBUG*/);
			CString strResult;
			Upload.UploadImages(strURL, strFormDataPairs, lElemWidth, lElemHeight, 70/*nQuality*/, strResult);
			if (strResult.Find("error") < 0 && strResult.Find("http") >= 0)
			{
				GetImageHost(strResult);
				strFileName = strResult;
				//::MessageBox(NULL, String("The photo was uploaded first to %s.", strFileName), g_szAppName, MB_OK);
			}
			else
			{
				CString szMsg;
				szMsg.LoadString(IDS_ADDAPHOTO_ERROR);
				::MessageBox(NULL, szMsg, g_szAppName, MB_OK);
				if (spMarkup2)
					hr = spMarkup2->EndUndoUnit();
				return;
			}
		}

		if (lImageWidth && lImageHeight)
		{
			ScaleToFit(&lElemWidth, &lElemHeight, lImageWidth, lImageHeight, true/*bUseSmallerFactor*/);
			SetImgElemSize(spImgElem, lElemWidth, lElemHeight);
			SetElemStyle(spElem, lElemWidth, lElemHeight);
		}

		hr = spImgElem->put_src(CComBSTR(strFileName));

		if (spMarkup2)
		{
			hr = spMarkup2->EndUndoUnit();
			CComQIPtr<IMarkupContainer2> spMarkupCont2 = spMarkup2;
			if (spMarkupCont2)
			{
				long l = spMarkupCont2->GetVersionNumber();
				l += 0;
			}
		}

		if (FAILED(hr))
			return;
	}
}
Esempio n. 30
0
//-----------------------------------------------------------------------------
int Builder::Build(bool upload)
{
    config.avrPath = config.arduinoInstall + "/hardware/tools/avr/bin";
    msg.ClearOutput();
    msg.ClearBuildMessages();

    progress = new BuildWindow((QWidget *)(this->parent())); //"Task in progress...", "Cancel", 0, 100, (QWidget *)this->parent());
    progress->setWindowModality(Qt::WindowModal);
    progress->SetPhase(BuildWindowTypes::compiling);
    SetPercentage(0);
    progress->show();
    qApp->processEvents();
    running = true;

    project = workspace.GetCurrentProject();
    if (project == NULL) {
        return -1;
    }

    if (project->rebuild) {
        if (Clean()) {
            project->rebuild = false;
        }
    }

    map <QString, BoardDef>::const_iterator board = config.boards.find(project->boardName);
    if (board == config.boards.end()) {
        msg.Add("Could not find board configuration for project: " + project->name, mtError);
        return false;
    }

    // Create the build directory
    buildPath = config.workspace + "/" + project->name + "/build"; //QDir().tempPath() + "/mariamole/build/" + project->name;
    QDir().mkpath(buildPath);

    // Get core lib filename
    coreLib = buildPath + "/arduino_core_" + board->second.build_variant+".a";

    msg.ClearBuildInfo();

    msg.AddOutput("Detecting undeclared functions in main project file: " + project->name + ".cpp...", false);

    if (config.useAutoGeneratedFile) {
        ImportDeclarations();
    }
    bool ok = true;
    for (unsigned int i=0; i < project->files.size(); i++) {
        QString ext = QFileInfo(project->files.at(i).name).suffix().toUpper();
        if ((ext == "CPP") || (ext == "C")) {
            ok = ok & Compile(i);
            if (GetCancel()) {
                msg.Add("Build cancelled by the user!", mtRegular);
                ok = false;
                break;
            }
            SetPercentage(40 * i / project->files.size());
            //SleepEx(1500, true);
        }
    }

    //QThread::sleep(5);

    if (GetCancel()) {
        msg.Add("Build cancelled by the user!", mtRegular);
        ok = false;
    }

    if (ok) {
        ok = Link();
        if (ok) {
            msg.Add("Project " + project->name + " successfully built!", mtSuccess);
            GetBinarySize();
        } else {
            msg.Add("Error linking project " + project->name, mtError);
        }
    } else {
        msg.Add("Error while building project " + project->name + ".", mtError);
    }

    if(ok && upload) {
        ok = Upload();
        if (ok) {
            msg.Add("Project " + project->name + " binaries successfully uploaded to board", mtSuccess);
        } else {
            if (project->programmer != "") {
                msg.Add("Error while uploading program to " + project->boardName
                        + " using programmer " +  project->programmer + ". Please check the output window for details", mtError);
            } else {
                msg.Add("Error while uploading program to " + project->boardName
                        + " via USB cable. Please check the output window for details", mtError);
            }
        }

        if (GetCancel()) {
            msg.Add("Build cancelled by the user!", mtRegular);
            ok = false;
        }
    }
    if (ok) {
        lastBuildStatus = 2;
    } else {
        lastBuildStatus = 1;
    }

    running = false;
    progress->hide();
    delete progress;
    return ok;
}