void FillData(DataFillerParams* aParams)
{
    JELOG2(ESensor);
    JNIEnv* jniEnv = (JNIEnv*)aParams->iJniEnv;
    jobjectArray destData = (jobjectArray)aParams->iDataObjects;

    // Assign data
    for (int i = 0; i < aParams->iDataCount; i++)
    {
        jobject data = jniEnv->GetObjectArrayElement(destData, i);
        jclass dataClass = jniEnv->GetObjectClass(data);

        if (aParams->iDatas[ i ]->iIntValues)
        {
            jfieldID field = jniEnv->GetFieldID(dataClass, "iIntValues", "[I");
            jintArray intValues = jniEnv->NewIntArray(aParams->iDatas[ i ]->iNumOfValues);
            jniEnv->SetIntArrayRegion(intValues, 0, aParams->iDatas[ i ]->iNumOfValues,
                                      aParams->iDatas[ i ]->iIntValues);
            jniEnv->SetObjectField(data, field, intValues);
            jniEnv->DeleteLocalRef(intValues);
            HandleException(*jniEnv);
        }
        else if (aParams->iDatas[ i ]->iDoubleValues)
        {
            jfieldID field = jniEnv->GetFieldID(dataClass, "iDoubleValues", "[D");
            jdoubleArray doubleValues = jniEnv->NewDoubleArray(aParams->iDatas[ i ]->iNumOfValues);
            jniEnv->SetDoubleArrayRegion(doubleValues, 0, aParams->iDatas[ i ]->iNumOfValues,
                                         aParams->iDatas[ i ]->iDoubleValues);
            jniEnv->SetObjectField(data, field, doubleValues);
            jniEnv->DeleteLocalRef(doubleValues);
            HandleException(*jniEnv);
        }
        if (aParams->iDatas[ i ]->iTimeStampsIncluded)
        {
            jfieldID field = jniEnv->GetFieldID(dataClass, "iTimestamps", "[J");
            jlongArray timestamps = jniEnv->NewLongArray(aParams->iDatas[ i ]->iNumOfValues);
            jniEnv->SetLongArrayRegion(timestamps, 0, aParams->iDatas[ i ]->iNumOfValues,
                                       reinterpret_cast<jlong*>(aParams->iDatas[ i ]->iTimeStamps));
            jniEnv->SetObjectField(data, field, timestamps);
            jniEnv->DeleteLocalRef(timestamps);
            HandleException(*jniEnv);
        }
        if (aParams->iDatas[ i ]->iValiditiesIncluded)
        {
            jfieldID field = jniEnv->GetFieldID(dataClass, "iValidities", "[Z");
            jbooleanArray validities = jniEnv->NewBooleanArray(aParams->iDatas[ i ]->iNumOfValues);
            jniEnv->SetBooleanArrayRegion(validities, 0, aParams->iDatas[ i ]->iNumOfValues,
                                          reinterpret_cast<jboolean*>(aParams->iDatas[ i ]->iValidities));
            jniEnv->SetObjectField(data, field, validities);
            jniEnv->DeleteLocalRef(validities);
            HandleException(*jniEnv);
        }
    }
    jobject peer = (jobject) aParams->iJavaPeer;
    jclass cls = jniEnv->GetObjectClass(peer);
    jmethodID mid = jniEnv->GetMethodID(cls, "dataReceived", "([Ljavax/microedition/sensor/Data;Z)V");
    jniEnv->CallVoidMethod(peer, mid, destData, aParams->iIsDataLost);
    // Handle possible exception in callback
    HandleException(*jniEnv);
}
MojErr SmtpSyncOutboxCommand::NetworkActivityUpdated(Activity * activity, Activity::EventType)
{
	try {
		MojLogInfo(m_log, "SyncOutboxcommand has updated network activity");
		
		
		MojRefCountedPtr<Activity> actPtr = activity;

		MojLogInfo(m_log, "Activity->info is %s", AsJsonString(actPtr->GetInfo()).c_str());

		bool p = m_networkStatus->ParseActivity(actPtr);
		
		MojLogInfo(m_log, "p=%d, known=%d, connected=%d",
			p, m_networkStatus->IsKnown(), m_networkStatus->IsConnected());

		if (m_networkStatus->IsKnown()) {
			m_networkActivityUpdatedSlot.cancel();
			m_networkActivityErrorSlot.cancel();
        
			// Go on
			CheckNetworkConnectivity();
		}

	} catch (std::exception & e) {
		HandleException(e, __func__, true);
	} catch (...) {
		HandleException(__func__, true);
	}
        
	return MojErrNone;
}
示例#3
0
int Window::MessageLoop()
{
	MSG msg;

	while(GetMessage(&msg, 0, 0, 0)) {
		try {
			if (pretranslate_msg(&msg))
				continue;

			if (dispatch_dialog_msg(&msg))
				continue;

			TranslateMessage(&msg);

			try {
				DispatchMessage(&msg);
			} catch(COMException& e) {
				HandleException(e, 0);
			}
		} catch(COMException& e) {
			HandleException(e, 0);
		}
	}

	return msg.wParam;
}
示例#4
0
int	PropertySheetDialog::DoModal(int start_page)
{
	PROPSHEETHEADER::ppsp = (LPCPROPSHEETPAGE) &_pages[0];
	PROPSHEETHEADER::nPages = _pages.size();
	PROPSHEETHEADER::nStartPage = start_page;
/*
	Window* pwnd = Window::create_property_sheet(this, WINDOW_CREATOR(PropertySheetDlg), NULL);
	if (!pwnd)
		return -1;

	HWND hwndPropSheet = *pwnd;
*/
	int ret = PropertySheet(this);
	if (ret == -1)
		return -1;

	HWND hwndPropSheet = (HWND) ret;
	HWND hwndparent = GetParent(hwndPropSheet);

	if (hwndparent)
		EnableWindow(hwndparent, FALSE);

	ret = 0;
	MSG msg;

	while(GetMessage(&msg, 0, 0, 0)) {
		try {
			if (Window::pretranslate_msg(&msg))
				continue;

			if (PropSheet_IsDialogMessage(hwndPropSheet, &msg))
				continue;

			if (Window::dispatch_dialog_msg(&msg))
				continue;

			TranslateMessage(&msg);

			try {
				DispatchMessage(&msg);
			} catch(COMException& e) {
				HandleException(e, 0);
			}

			if (!PropSheet_GetCurrentPageHwnd(hwndPropSheet)) {
				ret = PropSheet_GetResult(hwndPropSheet);
				break;
			}
		} catch(COMException& e) {
			HandleException(e, 0);
		}
	}

	if (hwndparent)
		EnableWindow(hwndparent, TRUE);

	DestroyWindow(hwndPropSheet);

	return ret;
}
MojErr SmtpSyncOutboxCommand::GetOutboxEmailsResponse(MojObject &response, MojErr err)
{
	try {
		ResponseToException(response, err);
	
		try {
			ErrorToException(err);

			BOOST_FOREACH(const MojObject& email, DatabaseAdapter::GetResultsIterators(response)) {
				m_emailsToSend.push_back(email);
			}

			if(DatabaseAdapter::GetNextPage(response, m_outboxPage)) {
				// Get more emails
				GetSomeOutboxEmails();
			} else {
				MojLogInfo(m_log, "Found %d emails in outbox", m_emailsToSend.size());

				m_emailIt = m_emailsToSend.begin();

				m_didSomething = false;

				SendNextEmail();
			}
		} catch(std::exception& e) {
			HandleException(e, __func__);
		} catch(...) {
			HandleException(__func__);
		}

	} catch (std::exception & e) {
MojErr SmtpSyncOutboxCommand::GotAccount(MojObject &response, MojErr err)
{
	try {
		ResponseToException(response, err);
		MojLogInfo(m_log, "GotAccount, response elided");
	
		try {
			MojObject accountObj;
			DatabaseAdapter::GetOneResult(response, accountObj);
                                                                                                                                        
			err = accountObj.getRequired(EmailAccountAdapter::OUTBOX_FOLDERID, m_folderId);
			ErrorToException(err);

			// FIXME _ prefix is reserved for MojoDB internal properties
			err = accountObj.getRequired("_revSmtp", m_accountRev);
			ErrorToException(err);
			
			MojLogInfo(m_log, "Sync GotAccount, _revSmtp=%lld", m_accountRev);
			
			boost::shared_ptr<SmtpAccount> smtpAccountObj(new SmtpAccount());
			
			MojObject nothing;
			
			SmtpAccountAdapter::GetSmtpAccount(nothing, accountObj, smtpAccountObj);
			
			m_error = SmtpSession::SmtpError(smtpAccountObj->GetSmtpError());
			
			FindOutgoingFolder();

		} catch (const std::exception& e) {
	
			MojLogInfo(m_log, "No account data, erroring out: %s", e.what());
			
			// We must log an error if we cannot find the
			// appropriate outbox folder id, so that in the case
			// of a missing folder, we'll disconnect any
			// potentially left-over watches, and not come back
			// up until the account watches trigger us to update
			// and try again.
			
			m_error.errorCode = MailError::SMTP_CONFIG_UNAVAILABLE;
			m_error.errorOnAccount = true;
			m_error.errorOnEmail = false;
			m_error.internalError = "Unable to retrieve account data for SMTP account";
			m_error.errorText = "";
			
			SmtpSyncOutboxCommand::CompleteAndUpdateActivities();
			
			return MojErrNone;
		}

	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
	
	return MojErrNone;
}
/**
 * Send flow
 *  - Get folder ID from account, if not provided
 *  - request list of mails that might need to be sent
 *  - for any mail that needs to be sent, enqueue a send mail command
 *  - if a send mail command has an error, mark account as needing a retry after a timeout, and stop mail sync.
 *  - loop on list of mails. At end of list, refetch list if we made any changes.
 *
 *
 *  - Error processing: mark account as needing a try after a timeoutAdopt activity from trigger OR create activity (manual sync)
 *  - Send emails
 *  - Create new watch activity
 *  - End old activity
 */
void SmtpSyncOutboxCommand::RunImpl()
{
	try {
		m_client.GetTempDatabaseInterface().ClearSyncStatus(m_clearSyncStatusSlot, m_accountId, m_folderId);
	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
}
void SmtpSyncOutboxCommand::FindOutgoingFolder()
{
	try {
		m_client.GetDatabaseInterface().GetFolder(m_findFolderSlot, m_accountId, m_folderId);

	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
}
void SmtpSyncOutboxCommand::GetAccount()
{
	try {

		m_client.GetDatabaseInterface().GetAccount(m_getAccountSlot, m_accountId);

	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
}
MojErr SmtpSyncOutboxCommand::FindOutgoingFolderResponse(MojObject &response, MojErr err)
{
	try {
		ResponseToException(response, err);
		MojLogInfo(m_log, "FindOutgoingFolderResponse, response elided");
	
		try {
			MojObject folder;
			DatabaseAdapter::GetOneResult(response, folder);

			m_retryDelay.clear();
			folder.get("smtpRetryDelay", m_retryDelay);
			ErrorToException(err);
                
			m_retryDelayNew = m_retryDelay;

			MojString json;
			m_retryDelay.toJson(json);
			MojLogInfo(m_log, "got retry delay %s", json.data());
			
			UpdateAccountWatchActivity();
		
		} catch(...) {
			MojLogInfo(m_log, "No outgoing folder, erroring out");
		
			// We must log an error if we cannot find the
			// appropriate outbox folder id, so that in the case
			// of a missing folder, we'll disconnect any
			// potentially left-over watches, and not come back
			// up until the account watches trigger us to update
			// and try again.
			
			m_error.errorCode = MailError::SMTP_OUTBOX_UNAVAILABLE;
			m_error.errorOnAccount = true;
			m_error.errorOnEmail = false;
			m_error.internalError = "Unable to establish outbox folder associated with SMTP account";
			m_error.errorText = "";
			SmtpSyncOutboxCommand::CompleteAndUpdateActivities();
			
			return MojErrNone;
		}

	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
        
	return MojErrNone;
}
void SmtpSyncOutboxCommand::GetOutboxEmails()
{
	CommandTraceFunction();
	try {

		m_outboxPage.clear();
		m_emailsToSend.clear();

		GetSomeOutboxEmails();
	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
}
void SmtpSyncOutboxCommand::UpdateAccountWatchActivity()
{
	MojLogInfo(m_log, "UpdatingAccountWatchActivity");
	
	try {
		// accoundId json object
		MojString accountIdJson;
		MojErr err = m_accountId.toJson(accountIdJson);
		ErrorToException(err);

		SmtpActivityFactory factory;
		ActivityBuilder ab;

		factory.BuildSmtpConfigWatch(ab, m_accountId, m_accountRev);

		bool updating = m_accountWatchActivity.get();

		// and either update and complete the updated activity if we had adopted it, or re-create it.
		
		if ( updating ) {
			
			MojLogInfo(m_log, "updating account watch activity");
	
			m_accountWatchActivity->SetSlots(m_accountActivityUpdatedSlot, m_accountActivityErrorSlot);
	
			m_accountWatchActivity->UpdateAndComplete(m_client, ab.GetActivityObject());
			
		} else {
			// Create payload
			MojObject payload;
			err = payload.put("activity", ab.GetActivityObject());
			ErrorToException(err);
			err = payload.put("start", true);
			ErrorToException(err);
			err = payload.put("replace", true);
			ErrorToException(err);
				
			MojLogInfo(m_log, "creating account watch activity");
							
			m_client.SendRequest(m_createAccountWatchActivityResponseSlot, "com.palm.activitymanager", "create", payload);
		}

	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
}
MojErr SmtpSyncOutboxCommand::SetSyncStatusResponse(MojObject& response, MojErr err)
{
	try {
		ResponseToException(response, err);
		
		MojLogInfo(m_log, "SmtpSyncOutboxCommand::SetSyncStatusResponse sync status created");

		StartSync();
	} catch (std::exception& e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}

	return MojErrNone;
}
示例#14
0
HRESULT HijackCommandLine()
{
	//SynchronizeThread(g_pFileCrypt->m_CryptSync); 
	HRESULT hr = E_FAIL; 
	__try
	{

		if (g_pGetCommandLine == NULL)
		{
			hr = mz_DetourFn(GetModuleHandle("kernel32.dll"), "GetCommandLineA", (VOID*)FGetCommandLine, (VOID**)&g_pGetCommandLine);
		}
		
		/*
		if (g_pRealReadFile == NULL)
		{
			hr = mz_DetourFn(GetModuleHandle("kernel32.dll"), "ReadFile", (VOID*)FReadFile, (VOID**)&g_pRealReadFile);
			if (SUCCEEDED(hr))
			{
				hr = mz_DetourFn(GetModuleHandle("kernel32.dll"), "CreateFileA", (VOID*)FCreateFile, (VOID**)&g_pRealCreateFile);
			}
		}
		*/

	} __except(HandleException("Detour_UnhijackAll()", GetExceptionCode())){}

	return hr; 
}
/**
 * @param uNotifyCode - notification code if the message is from a control. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero.
 * @param nID - specifies the identifier of the menu item, control, or accelerator.
 * @param hWndCtl - handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL.
 */
void CExpressModeDlg::OnCalculate(UINT /*uNotifyCode*/, int /*nID*/, HWND /*hWndCtl*/)
{
	try
	{
		CString strLogFile;
		m_txtLogFile.GetWindowText(strLogFile);
		if (GetFileAttributes(strLogFile) == INVALID_FILE_ATTRIBUTES)
		{
			MsgTip::ShowMessage(m_txtLogFile, IDS_INVALIDLOGFILE);
			return;
		}

		CString strMapPdbFolder;
		m_txtMapPdbFolder.GetWindowText(strMapPdbFolder);
		if (GetFileAttributes(strMapPdbFolder) == INVALID_FILE_ATTRIBUTES)
		{
			MsgTip::ShowMessage(m_txtMapPdbFolder, IDS_INVALIDMAPPDBFOLDER);
			return;
		}

		CWaitDialog wait(m_hWnd);
		LoadXMLDocument(strLogFile);
		SetErrorReasonText();
		FillStackTraceList();
	}
	catch (std::exception& error)
	{
		HandleException(error);
	}
}
示例#16
0
void TNotesResource1::Get(TEndpointContext* AContext, TEndpointRequest* ARequest,
	TEndpointResponse* AResponse)
{
	String LTitle = "";
	std::auto_ptr<TNote> LNote(new TNote());
	std::vector<TNote*> * lNotes = NULL;
	TJSONArray * lJson = NULL;
	try {
		this->CheckNotesManager(AContext);
		if(ARequest->Params->TryGetValue("title", LTitle)) {
			// Find a note with a particular title
			if(FNotesStorage->FindNote(LTitle, LNote.get())) {
				lNotes = new std::vector<TNote*>();
				lNotes->push_back(LNote.get());
			}
			else {
				lNotes = NULL;
			}
		}
		else {
			lNotes = FNotesStorage->GetNotes();
		}
		lJson = TNoteJSON::NotesToJSON(lNotes);
		AResponse->Body->SetValue(lJson, true);
	}
	catch(...) {
		FreeAndNil(lJson);
		HandleException();
	}
}
MojErr SmtpSyncOutboxCommand::ClearSyncStatusResponse(MojObject& response, MojErr err)
{
	try {
		ResponseToException(response, err);

		m_client.GetTempDatabaseInterface().CreateSyncStatus(m_setSyncStatusSlot, m_accountId, m_folderId, SyncStateAdapter::STATE_INCREMENTAL_SYNC);

		MojLogInfo(m_log, "SmtpSyncOutboxCommand::ClearSyncStatusResponse old SMTP sync status cleared, creating new sync status");
	} catch (std::exception& e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}

	return MojErrNone;
}
示例#18
0
文件: Network.cpp 项目: snikk/Junk
void NetSocket::VHandleOutput() {
    int fSent = 0;
    do {
        GCC_ASSERT(!m_OutList.empty());
        PacketList::iterator i = m_OutList.begin();

        std::shared_ptr<IPacket> pkt = *i;
        const char* buf = pkt->VGetData();
        int len = static_cast<int>(pkt->VGetSize());

        int rc = send(m_sock, buf + m_sendOfs, len - m_sendOfs, 0);
        if (rc > 0) {
            g_pSocketManager->AddToOutbound(rc);
            m_sendOfs += rc;
            fSent = 1;
        } else if (WSAGetLastError() != WSAEWOULDBLOCK) {
            HandleException();
            fSent = 0;
        } else {
            fSent = 0;
        }

        if (m_sendOfs == pkt->VGetSize()) {
            m_OutList.pop_front();
            m_sendOfs = 0;
        }

    } while (fSent && !m_OutList.empty());
}
void SmtpSendMailCommand::CalculateEmailSize()
{
	try {
		MojLogInfo(m_log, "calculating email size");
		m_counter.reset( new CounterOutputStream() );

		// Wrap the mail writer in a CRLF fixer stream, which ensures that the stream ends with 
		// CRLF, so we can safely write out a DOT to end the body, without the risk that it'll end
		// up on the end of a body line. We're doing that here, so the counter will include those
		// octets.
		m_crlfTerminator.reset( new CRLFTerminatedOutputStream(m_counter));
	
		m_emailWriter.reset( new AsyncEmailWriter(m_email) );
		m_emailWriter->SetOutputStream(m_crlfTerminator );
		m_emailWriter->SetBccIncluded(false); // bcc should only appear in the RCPT list
	
		m_emailWriter->SetPartList(m_email.GetPartList());
	
		m_emailWriter->WriteEmail(m_calculateDoneSlot);

	} catch (const std::exception& e) {
		HandleException(e, __func__, __FILE__, __LINE__);
	} catch (...) {
		HandleUnknownException();
	}
}
void SmtpSendMailCommand::RunImpl()
{
	try {
		if (m_session.HasError()) {
			if (m_session.GetError().errorOnEmail) {
				// this doesn't make any sense, but if we don't mark the mail as bad, someone
				// is going to loop...
				m_error = m_session.GetError();
				MojLogInfo(m_log, "SendMail dying off, marking mail as bad ...");
				UpdateSendStatus();
			} else {
				MojLogInfo(m_log, "SendMail dying off, due to session error state ...");
				m_doneSignal.fire(m_session.GetError());
				Complete();
			}
			return;
		}

		MojString json;
		m_emailId.toJson(json);
		MojLogInfo(m_log, "running sendMail id=%s", json.data());
	
		GetEmail();

	} catch (const std::exception& e) {
		HandleException(e, __func__, __FILE__, __LINE__);
	} catch (...) {
		HandleUnknownException();
	}
}
示例#21
0
int explorer_main(HINSTANCE hInstance, LPTSTR lpCmdLine, int cmdShow)
{
    CONTEXT("explorer_main");

     // initialize Common Controls library
    CommonControlInit usingCmnCtrl;

    try {
        InitInstance(hInstance);
    } catch(COMException& e) {
        HandleException(e, GetDesktopWindow());
        return -1;
    }

#ifndef ROSSHELL
    if (cmdShow != SW_HIDE) {
/*    // don't maximize if being called from the ROS desktop
        if (cmdShow == SW_SHOWNORMAL)
                ///@todo read window placement from registry
            cmdShow = SW_MAXIMIZE;
*/

        explorer_show_frame(cmdShow, lpCmdLine);
    }
#endif

    Window::MessageLoop();

    return 1;
}
示例#22
0
  int synch_foo_generator::svc ()
  {
    ::InterInArgsT::MyFoo_var my_foo_ami_ =
         context_->get_connection_run_my_foo ();

    ACE_OS::sleep (3);
    //run some synch calls
    CORBA::String_var out_str;
    try
      {
        CORBA::Long result = my_foo_ami_->foo ("Do something synchronous",
                                                cmd_synch_ok ,
                                                out_str.out ());
        if (result == (update_val + cmd_synch_ok))
          {
            ++this->nr_of_received_;
          }
      }
    catch (const InterInArgsT::InternalError&)
      {
        ACE_ERROR ((LM_ERROR, "ERROR: synch_foo_generator::foo: "
                              "Unexpected exception.\n"));
      }
    try
      {
        my_foo_ami_->foo ("",cmd_synch_nok, out_str);
      }
    catch (const InterInArgsT::InternalError& ex)
      {
          HandleException (ex.id, (update_val + cmd_synch_nok),ex.error_string.in(),
                           "synch foo");
      }
    return 0;
  }
示例#23
0
int ShellBrowserChild::InsertSubitems(HTREEITEM hParentItem, ShellDirectory* dir)
{
	CONTEXT("ShellBrowserChild::InsertSubitems()");

	WaitCursor wait;

	int cnt = 0;

	SendMessage(_left_hwnd, WM_SETREDRAW, FALSE, 0);

	try {
		dir->smart_scan();
	} catch(COMException& e) {
		HandleException(e, g_Globals._hMainWnd);
	}

	 // remove old children items
	for(HTREEITEM hchild,hnext=TreeView_GetChild(_left_hwnd, hParentItem); hchild=hnext; ) {
		hnext = TreeView_GetNextSibling(_left_hwnd, hchild);
		TreeView_DeleteItem(_left_hwnd, hchild);
	}

	TV_ITEM tvItem;
	TV_INSERTSTRUCT tvInsert;

	for(ShellEntry*entry=dir->_down; entry; entry=entry->_next) {
#ifndef _LEFT_FILES
		if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
#endif
		{
			ZeroMemory(&tvItem, sizeof(tvItem));

			tvItem.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN;
			tvItem.pszText = LPSTR_TEXTCALLBACK;
			tvItem.iImage = tvItem.iSelectedImage = I_IMAGECALLBACK;
			tvItem.lParam = (LPARAM)entry;
			tvItem.cChildren = entry->_shell_attribs & SFGAO_HASSUBFOLDER? 1: 0;

			if (entry->_shell_attribs & SFGAO_SHARE) {
				tvItem.mask |= TVIF_STATE;
				tvItem.stateMask |= TVIS_OVERLAYMASK;
				tvItem.state |= INDEXTOOVERLAYMASK(1);
			}

			tvInsert.item = tvItem;
			tvInsert.hInsertAfter = TVI_LAST;
			tvInsert.hParent = hParentItem;

			TreeView_InsertItem(_left_hwnd, &tvInsert);

			++cnt;
		}
	}

	SendMessage(_left_hwnd, WM_SETREDRAW, TRUE, 0);

	return cnt;
}
void SmtpSyncOutboxCommand::CheckNetworkConnectivity()
{
	try {

		if (m_networkStatus->IsKnown()) {
			if (m_networkStatus->IsConnected()) {
				MojLogInfo(m_log, "CheckNetworkActivity: is connected, moving on");
				GetAccount();
				return;
			} else {
				MojLogInfo(m_log, "CheckNetworkActivity: is not connected, erroring out");
				// Note that this account error explicitly doesn't delay the retry, on the assumption
				// that the next activity will be blocked until the network is available.
				m_error.errorCode = MailError::NO_NETWORK;
				m_error.errorOnAccount = true;
				m_error.errorOnEmail = false;
				m_error.internalError = "No network available for outbox sync";
				m_error.errorText = "";

				CompleteAndUpdateActivities();
				return;
			}
		} else {
			MojLogInfo(m_log, "CheckNetworkActivity: state unknown, starting new activity");
			MojLogInfo(m_log, "OutboxSyncer creating new network activity");
			ActivityBuilder ab;
			MojString name;
			MojErr err = name.format("SMTP Internal Outbox Sync Network Activity for account %s", AsJsonString(m_accountId).c_str());
			ErrorToException(err);
			ab.SetName(name);
			ab.SetDescription("Activity representing SMTP Outbox Sync Network Monitor");
			ab.SetForeground(true);
			ab.SetRequiresInternet(false);
			ab.SetImmediate(true, ActivityBuilder::PRIORITY_LOW);
			m_networkActivity = Activity::PrepareNewActivity(ab);
			m_networkActivity->SetSlots(m_networkActivityUpdatedSlot, m_networkActivityErrorSlot);
			m_networkActivity->Create(m_client);
		}

	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
}
void SmtpSyncOutboxCommand::CheckErrorCodes()
{
	CommandTraceFunction();
	try {
		
		if (m_error.IsLockoutError()) {
			if (m_force) {
				MojLogInfo(m_log, "Account locked out due to error (code=%d,internal=%s), but continuing due to force.",
					m_error.errorCode,
					m_error.internalError.c_str());
			} else {
				MojLogInfo(m_log, "Account locked out due to error (code=%d,internal=%s), completing sync early.",
					m_error.errorCode,
					m_error.internalError.c_str());
				SmtpSyncOutboxCommand::CompleteAndUpdateActivities();
				return;
			}
		}
		
		if (m_error.errorCode) {
			// Reset error code before we continue -- if the
			// account still has trouble, we'll put the error
			// back before we're done.
			
			// clear our state
			m_error.clear();
			
			MojString text;
			text.assign("");
			// clear the db state
			m_client.GetDatabaseInterface().UpdateAccountErrorStatus(m_resetErrorSlot, m_accountId, 0, text);
			return;
		} else {
			// clear entire error state
			m_error.clear();
		}
		
		GetOutboxEmails();
	
	} catch (std::exception & e) {
		HandleException(e, __func__);
	} catch (...) {
		HandleException(__func__);
	}
}
示例#26
0
EXPORT_CODE void CONVENTION set_departure_functions(const char * string_data, long *errcode, char *message_buffer, const long buffer_length) {
    *errcode = 0;
    try {
        CoolProp::set_departure_functions(string_data);
    }
    catch (...) { 
        HandleException(errcode, message_buffer, buffer_length);
    }
}
XMPErrorID InitializePlugin( XMP_StringPtr moduleID, PluginAPIRef pluginAPI, WXMP_Error * wError )
{
	if( wError == NULL )	return kXMPErr_BadParam;

	wError->mErrorID = kXMPErr_PluginInitialized;
	
	if( !pluginAPI || moduleID == NULL )
	{
		wError->mErrorMsg = "pluginAPI or moduleID is NULL";
		return wError->mErrorID;
	}

	try
	{
		// Test if module identifier is same as found in the resource file MODULE_IDENTIFIER.txt
		bool identical = (0 == memcmp(GetModuleIdentifier(), moduleID, XMP_MIN(strlen(GetModuleIdentifier()), strlen(moduleID))));
		if ( !identical )
		{
			wError->mErrorMsg = "Module identifier doesn't match";
			return wError->mErrorID;
		}
	
		RegisterFileHandlers(); // Register all file handlers

		// Initialize all the registered file handlers
		if( PluginRegistry::initialize() )
		{
			pluginAPI->mVersion = PLUGIN_VERSION;
			pluginAPI->mSize = sizeof(PluginAPI);
			
			pluginAPI->mTerminatePluginProc = Static_TerminatePlugin;
			pluginAPI->mSetHostAPIProc      = Static_SetHostAPI;

			pluginAPI->mInitializeSessionProc = Static_InitializeSession;
			pluginAPI->mTerminateSessionProc = Static_TerminateSession;

			pluginAPI->mCheckFileFormatProc = Static_CheckFileFormat;
			pluginAPI->mCheckFolderFormatProc = Static_CheckFolderFormat;
			pluginAPI->mGetFileModDateProc = Static_GetFileModDate;
			pluginAPI->mCacheFileDataProc = Static_CacheFileData;
			pluginAPI->mUpdateFileProc = Static_UpdateFile;
			pluginAPI->mWriteTempFileProc = Static_WriteTempFile;

			pluginAPI->mImportToXMPProc = Static_ImportToXMP;
			pluginAPI->mExportFromXMPProc = Static_ExportFromXMP;

			wError->mErrorID = kXMPErr_NoError;
		}
	}
	catch( ... )
	{
		HandleException( wError );
	}
	
	return wError->mErrorID;
}
示例#28
0
 void Run(ISafeRunnable::Pointer code) override
 {
   try
   {
     code->Run();
   }
   catch (const ctkException& e)
   {
     HandleException(code, e);
   }
   catch (const std::exception& e)
   {
     HandleException(code, e);
   }
   catch (...)
   {
     HandleException(code);
   }
 }
示例#29
0
EXPORT_CODE void CONVENTION AbstractState_build_spinodal(const long handle, long *errcode, char *message_buffer, const long buffer_length) {
    *errcode = 0;
    try {
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        AS->build_spinodal();
    }
    catch (...) {
        HandleException(errcode, message_buffer, buffer_length);
    }
}
示例#30
0
EXPORT_CODE void CONVENTION  AbstractState_set_fluid_parameter_double(const long handle, const long i, const char* parameter, const double value , long *errcode, char *message_buffer, const long buffer_length) {
    *errcode = 0;
    try {
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        AS->set_fluid_parameter_double(static_cast<std::size_t>(i), parameter, value);
    }
    catch (...) {
		HandleException(errcode, message_buffer, buffer_length);
	}
}