Пример #1
0
/*******************************************************************************
  * @函数名称		log_write
  * @函数说明		write log, log base frame
  * @输入参数		file pointer
  * @输出参数		无
  * @返回参数		是否成功
*******************************************************************************/
uint8_t log_write(FIL *fil, uint8_t warning)
{
    FRESULT rc;

    UINT bw;

    uint8_t src[40] = {0};

    uint8_t time_data[40] = {0};

    get_curr_time(time_data,"分");
    strcat(src,"0:/");
    strcat(src,time_data);
    strcat(src,".txt");

    /* 写入文件 */
    rc = f_open(fil,src,FA_WRITE | FA_READ | FA_OPEN_ALWAYS);
    ERROR_TRACE(rc);
    if(fil->fsize==0){
        rc = f_write(fil, "           时间           总电压 电流 电池温度                        PCB温度 单体电压0.01V                                                   剩余容量 异常\r\n",
                   strlen("           时间           总电压 电流 电池温度                        PCB温度 单体电压0.01V                                                   剩余容量 异常")+2, &bw);
        ERROR_TRACE(rc);
    }

    log_write_content(fil,warning);

    rc = f_close(fil);
    ERROR_TRACE(rc);
    
    return true;
}
Пример #2
0
// -----------------------------------------------------------------------------
// RPsmServer::StartServer
// Starts server.
// -----------------------------------------------------------------------------
//
TInt RPsmServer::StartServer() const
    {
    COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::StartServer()" ) ) );

    RProcess server;
    const TUidType serverUid( KNullUid, KPsmServerUid2, KNullUid );
    TInt err = server.Create( ServerLocation(), // psmserver.exe
                              KNullDesC, // A descriptor containing data passed as 
                                         // an argument to the thread function of 
                                         // the new process's main thread, when it 
                                         // is first scheduled.
                              serverUid, // PSM server UID
                              EOwnerProcess ); // Ownership of this process handle 

    // Return error code if we couldn't create a process
    if ( err == KErrNone )
        {
        // Rendezvous is used to detect server start
        TRequestStatus stat;
        server.Rendezvous( stat );

        if ( stat != KRequestPending )
            {
            ERROR_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - ERROR: Rendezvous failure: %d" ), stat.Int() ) );
            server.Kill( 0 ); // Abort startup
            }
        else
            {
            server.Resume();  // Logon OK - start the server
            }

        COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - Waiting server startup" ) ) );

        User::WaitForRequest( stat ); // Wait for start or death

        COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - Server startup wait finished" ) ) );
        
        // We can't use the 'exit reason' if the server paniced as this
        // is the panic 'reason' and may be '0' which cannot be distinguished
        // from KErrNone
        if ( server.ExitType() == EExitPanic ) 
            {
            ERROR_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - ERROR: Server paniced at startup" ) ) );
            err = KErrGeneral;
            }
        else
            {
            err = stat.Int();
            }

        // We can close the handle now
        server.Close();        
        }

    COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - return %d" ), err ) );

    return err;
    }
Пример #3
0
// -----------------------------------------------------------------------------
// RPsmServer::Connect
// Connects to PSM server
// -----------------------------------------------------------------------------
//
TInt RPsmServer::Connect()
    {
    COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::Connect()" ) ) );

    // Try this twice
    TInt retry( KPsmClientTryCount );
    TInt err( KErrNone );

    while (retry > 0)
        {
        // Try to create a PSM Server session
        err = CreateSession( KPsmProcessName, 
                             ServerVersion(), 
                             KPsmServerDefaultAsyncSlots );

        COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::Connect - CreateSession returned: %d" ), err ) );        
        
        if ( err != KErrNotFound && err != KErrServerTerminated )
            {
            // KErrNone or unrecoverable error
            if (err != KErrNone)
                {
                ERROR_TRACE( ( _L( "PSM Client - RPsmServer::Connect - ERROR: CreateSession unrecoverable error: %d" ), err ) );
                }
            
            retry = 0;
            }
        else
            {
            // Return code was KErrNotFound or KErrServerTerminated.
            // Try to start a new PSM Server
            err = StartServer();

            COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::Connect - StartServer returned: %d" ), err ) );        

            if ( err != KErrNone && err != KErrAlreadyExists )
                {
                // Unrecoverable error
                ERROR_TRACE( ( _L( "PSM Client - RPsmServer::Connect - ERROR: StartServer unrecoverable error: %d" ), err ) );
                retry = 0;
                }
            }
                
        retry--;
        }
        
    COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::Connect - return %d" ), err ) );        
    return err;
    }
Пример #4
0
int CT_Line::i_GetParagraphTermWidth (CDC * pco_dc)
{
    CFont * pco_mfcFont = NULL;

//    if (i_GetTextLength() > 0)
//    {                
        pco_mfcFont = pco_Parent_->pco_GetWindowsFont (pco_dc, 
                                                       i_GetTextLength() - 1);
//    }
//    else
//    {
//        unsigned long ui_key = pco_Parent_->ul_GetFirstFd();
//        CT_FontDescriptor * pco_fd = pco_Parent_->
//                                        pco_GetFontDescriptor (ui_key);
//        pco_mfcFont = pco_fd->pco_GetWindowsFont (pco_dc);
//    }

    CFont * pco_oldFont = pco_dc->SelectObject (pco_mfcFont);
    TEXTMETRIC st_tm;
    BOOL mfcb_ = ::GetTextMetrics (pco_dc->GetSafeHdc(), &st_tm);
    if (!mfcb_)
    {
        ERROR_TRACE (_T("Error obtaining font info."));
        return 0;
    }
    pco_dc->SelectObject (pco_oldFont);
    return 2*st_tm.tmAveCharWidth;

}  //  i_GetParagraphTermWidth (...)
Пример #5
0
/*******************************************************************************
  * @函数名称		SDFont_Init
  * @函数说明		把cc936.c文件中的two big static buf,转移到SD卡中,之前必须先初始化sd卡
                    挂载文件系统,modify your own path
  * @输入参数       无
  * @输出参数		无
  * @返回参数		无
*******************************************************************************/
uint8_t SDFont_Init(void)
{
    FRESULT rc;
    
    FIL *uni_oem;  

    uni_oem=(FIL*)mymalloc(SRAMEX, sizeof(uni_oem));	      
    
    rc = f_open(uni_oem,"0:/system/UNIGBK.BIN",FA_OPEN_EXISTING|FA_READ);
    
    ERROR_TRACE(rc);
    
    if (!FR_OK) {
        f_close(uni_oem);
        
        myfree(SRAMEX, uni_oem);
        
        return 1;
    } else {
        UGBKSIZE=uni_oem->fsize;
        
        f_lseek(uni_oem,1);
        
        UGBKADDR = uni_oem->dsect;
        
        f_close(uni_oem);
        
        myfree(SRAMEX, uni_oem);
    }
    return 0;
}
// -----------------------------------------------------------------------------
// CMediatorEventProviderBody::UnregisterEvent
// Unregisters a single event.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt CMediatorEventProviderBody::UnregisterEvent( TUid aDomain,
                                                  TUid aCategory, 
                                                  TInt aEventId )
    {
    LOG(_L("[Mediator Server]\t CMediatorEventProviderBody::UnregisterEvent\n"));
    __UHEAP_MARK;
    
    // Create a list to contain one event
    REventList eventList;
    TEvent newEvent;
    newEvent.iEventId = aEventId;
    TInt error = eventList.Append( newEvent );
        
    if ( !error )
        {
        // Unregister eventlist
        error = iMediatorServer.UnregisterEventList( aDomain,
                                                     aCategory,
                                                     eventList );
        }
    else
        {
        ERROR_TRACE(Print(_L("[Mediator] CMediatorEventProviderBody::UnregisterEvent: error=%d\n"), error ) );
        }
                
    // Clean up                                        
    eventList.Reset();
    eventList.Close();
    
    __UHEAP_MARKEND;
    return error;
    }
// ---------------------------------------------------------------------------
// Starts cleanup timer
// ---------------------------------------------------------------------------
//
void CSensrvThreadMonitor::DelayedTermination()
    {
    COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::DelayedTermination(), monitored thread: %S" ), &iThreadName ) );

    // If thread is already terminated, notify proxy. Otherwise start 
    // a timer to kill threads forcefully.
    if (!iCleanupTimer)
        {
        if (IsActive())
            {
            TRAPD(err, iCleanupTimer = CSensrvTimer::NewL(*this, 
                                                          KSensrvTimerMaxTime,
                                                          CSensrvTimer::ETimerIdSsyCleanupTimer);)

            if (err == KErrNone)        
                {
                iCleanupTimer->Set(iProxy.ProxyManager().ThreadTerminationGracePeriod());
                }
            else
                {
                ERROR_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::DelayedTermination - ERROR: Unable to create timer: %d, Thread terminated immediately" ), err ) );
                Cancel();
                TerminateAndNotifyProxy();
                }
            }
        else
            {
Пример #8
0
int CT_Line::i_GetSpacing()
{
    int i_spacing = 0;

    ET_LineSpacingType eo_type = pco_Parent_->eo_GetSpacingType();
    switch (eo_type)
    {
        case ec_LineSpacingAuto:
        {
            i_spacing = (int)((double)i_GetLineHeight() * .2);
            break;
        }
        case ec_LineSpacingLines:
        {
            i_spacing = (int)((double)i_GetLineHeight() * 
                              ((double)pco_Parent_->i_GetSpacingSize()/100 - 1));
            break;
        }
        case ec_LineSpacingPoints:
        {
            i_spacing = pco_Parent_->i_GetSpacingSize()/10;
            break;
        }
        case ec_LineSpacingFront:
        case ec_LineSpacingBack:
        default:
        {
            ERROR_TRACE (_T("Bad spacing type."));
            i_spacing = (int)((double) i_GetLineHeight() * 1.2);
        }
    }

    return i_spacing;

}   //  i_GetSpacing()
Пример #9
0
void CT_Line::v_Print (CKaiView * pco_view, CDC * pco_dc, int i_xPos, int i_yPos)
{
    pco_dc->SetBkMode (TRANSPARENT);

    //
    // Justification done at time of rendering does not work for
    // printing. We'll have to re-calculate extra space and store it
    // temporarily with each compound.
    //
    if (!pco_dc->IsPrinting())
    {
        ERROR_TRACE (_T("Bad print DC"));
        return;
    }
    int i_y = i_yPos + i_GetLineHeight();

    if (b_IsRightJustified())
    {
        pco_Parent_->pco_Dc_ = pco_dc;

        unsigned int ui_font = 0;
        bool b_ = pco_Parent_->b_GetFontKey (0, ui_font);
        for (int i_t = 0; i_t < i_NTokens_; ++i_t)
        {
            ST_Token& rst_token = pco_Parent_->vo_Tokens_[i_FirstToken_ + i_t];
            rst_token.i_PrintLength = 0;
            rst_token.i_ExtraPrintSpace = 0;
            if (rst_token.b_IsLinearText())
            {
                pco_Parent_->b_MeasureToken (rst_token, ui_font);
            }
            if (ec_TokenFormatting == rst_token.eo_TokenType)
            {
                ui_font = rst_token.ui_FontDescriptor;
            }
        }
        bool b_isPrinting = true;
        b_RightJustify (b_isPrinting);
    }

    int i_offset = i_xPos;
    for (int i_t = 0; i_t < i_NTokens_; ++i_t)
    {
        ST_Token& rst_token = pco_Parent_->vo_Tokens_[i_FirstToken_ + i_t];
        if (0 == i_t)
        {
            CFont * pco_font = pco_Parent_->pco_GetWindowsFont (pco_dc, 
                                                                rst_token.i_Offset);
            CFont * pco_oldFont = pco_dc->SelectObject (pco_font);
        }
        i_offset += i_ShowToken (pco_dc, i_t, i_offset, i_y);
//        if (b_IsRightJustified())
//        {
//            i_offset += rst_token.i_ExtraPrintSpace;
//        }

        pco_Parent_->pco_Dc_ = NULL;
    }

}  // v_Print (...)
// ---------------------------------------------------------------------------
// Adds property to the end of the queue
// ---------------------------------------------------------------------------
//
TInt CSensrvChannelChangeQueue::Append( const TSensrvChannelInfo& aChannelInfo,
                                        TSensrvChannelChangeType aChangeType )
    {
    COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvChannelChangeQueue::Append(Channel ID:%d)" ), aChannelInfo.iChannelId ) );

    TInt err(KErrNone);

    // Allocate linkable transaction pointer in same heap as queue
    TChannelChangeNotification* newPtr = new TChannelChangeNotification();
    
    if (newPtr)
        {
        newPtr->iChannelInfo = aChannelInfo;
        newPtr->iChangeType = aChangeType;
        iChangesList.AddLast(*newPtr);                
        }
    else
        {
        ERROR_TRACE( ( _L( "Sensor Server - CCSensrvChannelChangeQueue::Append - ERROR: No memory to add item" ) ) );
        err = KErrNoMemory;
        }

    COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvChannelChangeQueue::Append - return %d" ), err ) );
    
    return err;
    }
Пример #11
0
bool CT_Line::b_ParagraphOffsetFromLineOffset (int i_lineOffset, 
                                               int& i_paragraphOffset)
{
    if (i_lineOffset >= i_GetVisibleTextLength())
    {
        ATLASSERT (i_lineOffset == i_VisibleTextLength_);
        i_paragraphOffset = i_TextLength_;
        return true;
    }

    i_paragraphOffset = 0;

    //
    // Count all complete tokens on the left
    //
    int i_wholeTokenVisibleLength = 0;
    int i_partialLength = 0;
    int i_t = 0;
    for (; i_t < i_NTokens_; ++i_t)
    {
        ST_Token& rst_t = pco_Parent_->vo_Tokens_[i_FirstToken_ + i_t];
        if (!rst_t.b_IsLinearText())
        {
            continue;
        }

        int i_tokenLength = i_GetTokenLength (i_t);
        if (i_wholeTokenVisibleLength + i_tokenLength > i_lineOffset)
        {
             i_partialLength = i_lineOffset - i_wholeTokenVisibleLength;
             break;
        }

        i_wholeTokenVisibleLength += i_tokenLength;
//        i_paragraphOffset += i_GetTokenOffset (i_t) + i_tokenLength;
    }
    if (i_NTokens_ == i_t)
    {
        ERROR_TRACE (_T("Token out of range."));
        return false;
    }

    i_paragraphOffset = i_GetTokenOffset (i_t) + i_partialLength;

    if (0 == i_partialLength)
    {
        if (0 < i_t)
        {
            ST_Token& rst_t = pco_Parent_->vo_Tokens_[i_t-1];
            if (ec_TokenDiacritics == rst_t.eo_TokenType)
            {
                i_paragraphOffset = rst_t.i_Offset;
            }
        }
    }

    return true;

}    //  b_ParagraphOffsetFromLineOffset
Пример #12
0
bool
mp_app_noti_ignore(void)
{
	sound_manager_unset_available_route_changed_cb();
	sound_manager_unset_active_device_changed_cb();

	if (vconf_ignore_key_changed(VCONFKEY_FILEMANAGER_DB_STATUS, _mp_app_noti_changed_cb) < 0)
	{
		ERROR_TRACE("Error when ignore callback\n");
		return FALSE;
	}
	if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, _mp_app_noti_changed_cb) < 0)
	{
		ERROR_TRACE("Error when ignore callback\n");
		return FALSE;
	}

	if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_EARJACKKEY, _mp_app_noti_changed_cb) < 0)
	{
		ERROR_TRACE("Error when ignore callback\n");
		return FALSE;
	}

	if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, _mp_app_noti_changed_cb) < 0)
	{
		ERROR_TRACE("Error when ignore callback\n");
		return FALSE;
	}

	if (vconf_ignore_key_changed(MP_VCONFKEY_PLAYING_PID, _mp_app_noti_changed_cb) < 0)
	{
		ERROR_TRACE("Error when ignore callback\n");
		return FALSE;
	}

#ifdef MP_FEATURE_AVRCP_13
	mp_avrcp_target_finalize();
#endif

	if(gNotiPipe)
	{
		ecore_pipe_del(gNotiPipe);
		gNotiPipe = NULL;
	}
	return TRUE;
}
Пример #13
0
int
mp_app_inotify_add_watch(const char *path, mp_inotify_cb callback, void *user_data)
{
	mp_inotify_t *handle = NULL;
	GList *wd_list;
	int wd;

	handle = g_handle;
	MP_CHECK_VAL(handle, -1);

	pthread_mutex_lock(&mp_noti_lock);

	wd_list = handle->wd_list;
	wd = inotify_add_watch(handle->fd, path, MP_WATCH_FLAGS);
	if (wd < 0)
	{
		switch (errno)
		{
		case EACCES:
			ERROR_TRACE("Read access to the given file is not permitted.\n");
			break;
		case EBADF:
			ERROR_TRACE("The given file descriptor is not valid.\n");
			handle->fd = -1;
			break;
		case EFAULT:
			ERROR_TRACE("pathname points outside of the process's accessible address space.\n");
			break;
		case EINVAL:
			ERROR_TRACE
				("The given event mask contains no legal events; or fd is not an inotify file descriptor.\n");
			break;
		case ENOMEM:
			ERROR_TRACE("Insufficient kernel memory is available.\n");
			break;
		case ENOSPC:
			ERROR_TRACE
				("The user limit on the total number of inotify watches was reached or the kernel failed to allocate a needed resource.\n");
			break;
		default:
			ERROR_TRACE("Fail to mp_inotify_add_watch(), Unknown error.\n");
			break;
		}
		pthread_mutex_unlock(&mp_noti_lock);
		return -1;
	}

	wd_list = g_list_append(wd_list, (gpointer)wd);
	if(!wd_list) {
		DEBUG_TRACE("g_list_append failed");
		pthread_mutex_unlock(&mp_noti_lock);
		return -1;
	}

	handle->callback = callback;
	handle->u_data = user_data;
	pthread_mutex_unlock(&mp_noti_lock);

	return 0;
}
// ---------------------------------------------------------------------------
// Starts monitoring thread
// ---------------------------------------------------------------------------
//
TInt CSensrvThreadMonitor::StartMonitoring(const RThread& aThread)
    {
    COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::StartMonitoring()" ) ) );

    TInt err(KErrNone);

    if (aThread.Handle())
        {
        // If for some reason old iThread is still active, kill it.
        if ( (iThread.Handle()) && 
             (iThread.Handle() != RThread().Handle()) )
            {
            ERROR_TRACE( ( _L( "Sensor Sever - CSensrvThreadMonitor::StartMonitoring - ERROR: Old thread was still active, killing it." ) ) );
            iThread.LogonCancel(iStatus);
            iThread.Terminate(KErrCancel);
            iThread.Close();
            }
        
        // Old cleanuptimer needs to be deleted
        delete iCleanupTimer;
        iCleanupTimer = NULL;
        
        err = iThread.Open(aThread.Id());
        
        if (err == KErrNone)
            {
            iThread.Logon(iStatus);
            SetActive();

#if defined (COMPONENT_TRACE_FLAG) || defined(ERROR_TRACE_FLAG)
            iThreadName = iThread.Name();
#endif
            }
        }
    else
        {
        ERROR_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::StartMonitoring - ERROR: NULL handle" ) ) );
        err = KErrBadHandle;
        }
    
    COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::StartMonitoring - return %d" ), err ) );
   
    return err;
    }
Пример #15
0
void CKaiDoc::v_CreateDeafultParagraph (CT_Paragraph *& pco_paragraph)
{
    int i_defaultLineWidth = 0;
    int i_defaultLeftIndent = 0;
    int i_defaultRightIndent = 0;
    int i_defaultSpacing = 0;
    ET_Alignment eo_defaultAlignment = ec_AlignmentFront;

    bool b_ = pco_Doc_->b_GetDefaultParStyle (i_defaultLineWidth,
                                              i_defaultLeftIndent,
                                              i_defaultRightIndent,
                                              eo_defaultAlignment);
    if (!b_)
    {
        STL_STRING str_ (_T("Warning: Unable to find default paragraph style"));
        ERROR_TRACE (str_);
        i_defaultLineWidth = 800;
        i_defaultSpacing = 10;
        eo_defaultAlignment = ec_Left;
    }

    pco_Doc_->v_SetMaxParagraphWidth (i_defaultLineWidth);

    STL_STRING str_typeface;
    int i_size = 0;
    ET_Charset eo_charset = ec_CharsetFront;
    b_ = pco_Doc_->b_GetDefaultFont (str_typeface, i_size, eo_charset);
    if (!b_)
    {
        ERROR_TRACE (_T("Warning: b_GetDefaultFont returned \"false\""));
        str_typeface = _T("Courier New");
        i_size = 10;
        eo_charset = ec_RussianCharset;
    }

    CT_FontDescriptor co_fd (CT_KaiString (str_typeface), eo_charset, i_size);
    pco_Doc_->v_CreateDefaultParagraph (i_defaultLeftIndent,
                                        i_defaultRightIndent,
                                        eo_defaultAlignment,
                                        STL_STRING(_T("")),
                                        co_fd,
                                        pco_paragraph);

}    //  v_CreateDeafultParagraph (...)
// -----------------------------------------------------------------------------
// CMediatorServerObjectHandler::CategoryL
// Returns pointer to found category
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//     
CCategory* CMediatorServerObjectHandler::CategoryL( TMediatorCategory aCategory )
    {
    // Check that domain exists 
    CDomain* domain = FindDomain( aCategory.iDomain );
    if ( !domain )
        {
        ERROR_TRACE(Print(_L("[Mediator] CMediatorServerObjectHandler::CategoryL: domain %d not found\n"), aCategory.iDomain ) );
        User::Leave( KErrMediatorDomainNotFound );
        }
    // Check that category exists
    TInt index = 0; // not used
    CCategory* category = domain->FindCategory( aCategory.iCategory, index );
    if ( !category )
        {
        ERROR_TRACE(Print(_L("[Mediator] CMediatorServerObjectHandler::CategoryL: category %d not found\n"), aCategory.iCategory ) );
        User::Leave( KErrMediatorCategoryNotFound );
        }
    return category;
    }
Пример #17
0
void CKaiView::OnLButtonUp (UINT ui_flags, CPoint co_point) 
{
    b_LButtonDown_ = false;

    //
    // Resizing text window?
    //
    if (b_TrackRightBorder_)
    {
        b_TrackRightBorder_ = false;
        co_point.x = max (ec_MinLineWidth_, co_point.x);
        v_Track_ (co_point.x);
        int i_pixPerInch = pco_MemDC_->GetDeviceCaps (LOGPIXELSX);
        CT_DocDescriptor * pco_doc = pco_GetDocDescriptor_();
        pco_doc->v_SetMaxParagraphWidth ((i_TrackerPos_*100)/i_pixPerInch);
        i_TrackerPos_ = -1;
        eo_RefreshMode_ = ec_WholeScreen;
        for (int i_ = 0; i_ < pco_doc->i_NParagraphs(); ++i_)
        {
            CT_Paragraph * pco_p = pco_doc->pco_GetParagraph (i_);
            pco_p->v_Invalidate();
            pco_p->b_Render (pco_MemDC_);
        }
        pco_CaretPos_->v_Invalidate (CT_TextPos::ec_ParagraphPos);
        st_DisplayWindow_.v_Reset (*pco_CaretPos_);
        InvalidateRect (NULL, TRUE);
        UpdateWindow();
        pco_CaretPos_->v_Invalidate (CT_TextPos::ec_ParagraphPos);
        bool b_ = b_RepositionCaret_();
    }

    if (!b_Rendered_)
    {
        return;
    }

    //
    // Selection in progress?
    //
    if (GetCapture())
    {
        BOOL mfcb_result = ReleaseCapture();
        if (mfcb_result == 0)
        {
            DWORD dw_error = GetLastError();
            STL_STRING str_errorMsg;
            bool b_ = B_FormatWindowsMessage (dw_error, str_errorMsg);
            str_errorMsg = _T("ReleaseCapture() failed: ") + str_errorMsg;
            ERROR_TRACE (str_errorMsg);
        }
    }

    CView::OnLButtonUp (ui_flags, co_point);

}  // OnLButtonUp
Пример #18
0
int
mp_app_inotify_rm_watch(int wd)
{
	int ret = -1;
	mp_inotify_t *handle = NULL;

	handle = g_handle;
	mp_retvm_if(handle == NULL, -1, "handle is NULL");

	if (handle->fd < 0 || wd < 0)
	{
		WARN_TRACE
			("inotify is not initialized or has no watching dir - fd [%d] wd [%d]",
			 handle->fd, wd);
		return 0;
	}

	pthread_mutex_lock(&mp_noti_lock);

	ret = inotify_rm_watch(handle->fd, wd);
	if (ret < 0)
	{
		switch (errno)
		{
		case EBADF:
			ERROR_TRACE("fd is not a valid file descriptor\n");
			handle->fd = -1;
			break;
		case EINVAL:
			ERROR_TRACE("The watch descriptor wd is not valid; or fd is not an inotify file descriptor.\n");
			break;
		default:
			ERROR_TRACE("Fail to mp_inotify_add_watch(), Unknown error.\n");
			break;
		}
		pthread_mutex_unlock(&mp_noti_lock);
		return -1;
	}
	pthread_mutex_unlock(&mp_noti_lock);

	return 0;
}
Пример #19
0
int
mp_app_inotify_init(void *data)
{

	struct appdata *ad = data;

	mp_inotify_t *handle = NULL;
	handle = _mp_app_inotify_handle_init();
	mp_retvm_if(handle == NULL, -1, "fail to _mp_app_inotify_handle_init()");

	handle->fd = inotify_init();

	if (handle->fd < 0)
	{
		switch (errno)
		{
		case EMFILE:
			ERROR_TRACE("The user limit on the total number of inotify instances has been reached.\n");
			break;
		case ENFILE:
			ERROR_TRACE("The system limit on the total number of file descriptors has been reached.\n");
			break;
		case ENOMEM:
			ERROR_TRACE("Insufficient kernel memory is available.\n");
			break;
		default:
			ERROR_TRACE("Fail to inotify_init(), Unknown error.\n");
			break;
		}
		return -1;
	}
	pthread_create(&handle->monitor, NULL, _mp_app_inotify_watch_thread, handle);

	_mp_app_inotify_add_recursive_watch(MP_MMC_ROOT_PATH, ad);
	_mp_app_inotify_add_recursive_watch(MP_PHONE_ROOT_PATH, ad);

	ad->inotify_pipe = ecore_pipe_add(_mp_app_pipe_cb, (const void *)ad);

	return 0;
}
Пример #20
0
char PrimitiveValueNode::getChar() const
{

    if( valueType != CHAR_TYPE )
	{
        //throw decaf::util::NoSuchElementException(
        //    __FILE__, __LINE__, "PrimitiveValue is not CHAR_TYPE" );
		ERROR_TRACE("not exist");
		return 0;
    }

    return value.charValue;
}
Пример #21
0
long long PrimitiveValueNode::getLong() const
{

    if( valueType != LONG_TYPE )
	{
        //throw decaf::util::NoSuchElementException(
        //    __FILE__, __LINE__, "PrimitiveValue is not LONG_TYPE" );
		ERROR_TRACE("not exist");
		return 0;
    }

    return value.longValue;
}
Пример #22
0
float PrimitiveValueNode::getFloat() const
{

    if( valueType != FLOAT_TYPE )
	{
        //throw decaf::util::NoSuchElementException(
        //    __FILE__, __LINE__, "PrimitiveValue is not FLOAT_TYPE" );
		ERROR_TRACE("not exist");
		return 0;
    }

    return value.floatValue;
}
Пример #23
0
bool PrimitiveValueNode::getBool() const {

    if( valueType != BOOLEAN_TYPE )
	{
        //throw decaf::util::NoSuchElementException(
        //    __FILE__, __LINE__, "PrimitiveValue is not BOOLEAN_TYPE" );
		//not exist
		ERROR_TRACE("not exist");
		return false;
    }

    return value.boolValue;
}
Пример #24
0
double PrimitiveValueNode::getDouble() const
{

    if( valueType != DOUBLE_TYPE )
	{
        //throw decaf::util::NoSuchElementException(
        //    __FILE__, __LINE__, "PrimitiveValue is not DOUBLE_TYPE" );
		ERROR_TRACE("not exist");
		return 0;
    }

    return value.doubleValue;
}
Пример #25
0
unsigned char PrimitiveValueNode::getByte() const
{

    if( valueType != BYTE_TYPE )
	{
        //throw decaf::util::NoSuchElementException(
        //    __FILE__, __LINE__, "PrimitiveValue is not BYTE_TYPE" );
		ERROR_TRACE("not exist");
		return 0;
    }

    return value.byteValue;
}
Пример #26
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    printf("FATFS test\r\n");
    printf("please insert SD card...\r\n");
    if(SD_QuickInit(20*1000*1000))
    {
        printf("SD card init failed!\r\n");
        while(1);
    }
    printf("SD size:%dMB\r\n", SD_GetSizeInMB());
    FRESULT rc;
    FATFS fs_sd;
    FIL fil;
    FATFS *fs;
    fs = &fs_sd;
    UINT bw,br; /* bw = byte writted br = byte readed */
    DWORD fre_clust, fre_sect, tot_sect;
    /* 挂载文件系统 */
    rc = f_mount(fs, "0:", 0);
    ERROR_TRACE(rc);
    rc = f_getfree("0:", &fre_clust, &fs);
    ERROR_TRACE(rc);
    /* 计算磁盘空间及剩余空间 */
    tot_sect = (fs->n_fatent - 2) * fs->csize;
    fre_sect = fre_clust * fs->csize;
    printf("%d KB total drive space.\r\n%d KB available.\r\n", tot_sect / 2, fre_sect / 2);
    /* 写入文件 */
    printf("open or create file\r\n");
    rc = f_open(&fil, "0:/fatfs.txt", FA_WRITE | FA_CREATE_ALWAYS);
    ERROR_TRACE(rc);
    printf("write file\r\n");
    rc = f_write(&fil, "HelloWorld\r\n", 12, &bw);
    ERROR_TRACE(rc);
    printf("%d bytes writen\r\n", bw);
    rc = f_close(&fil);
    /* 读取文件 */
    rc = f_open(&fil, "0:/fatfs.txt", FA_READ);
    ERROR_TRACE(rc);
    printf("file size:%l\r\n", f_size(&fil));
    printf("file contents:\r\n");
    while(1)
    {
        rc = f_read(&fil, buf, sizeof(buf), &br);
        if(rc || !br ) break;
        printf("%s", buf);
    }
    rc = f_close(&fil);
    ERROR_TRACE(rc);
    
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
// -----------------------------------------------------------------------------
// RMediatorServer::Connect
// Creates a new client-server -session with MediatorServer. Starts it up if not
// started already.
// -----------------------------------------------------------------------------
//
TInt RMediatorServer::Connect()
	{
	// Check that there's no connection existing already
	if ( Handle() )
	    {
	    return KErrAlreadyExists;
	    }
	
    TInt tryLoop = 0;
    TInt error = 0;
    // Try to create session to server. If server is not started, try to start it.
    for ( tryLoop = 0; tryLoop < KServerRetries; tryLoop++ )
        {
        error = CreateSession( KMediatorServerName, Version() );   
        
        TRACE(Print(_L("[Mediator Server]\t Session created with status %d\n"), error));

        if ( error != KErrNotFound &&  error != KErrServerTerminated )
            {
            if ( error != KErrNone )
                {
                ERROR_TRACE(Print(_L("[Mediator] RMediatorServer::Connect(ln%d): error=%d\n"), __LINE__, error ) );    
                }
            
            return error;
            }

        error = StartServer();
        
        if ( error != KErrNone && error != KErrAlreadyExists )
            {
            ERROR_TRACE(Print(_L("[Mediator] RMediatorServer::Connect(ln%d): error=%d\n"), __LINE__, error ) );
            return error;
            }
            
        }
    return error;
	}
// -----------------------------------------------------------------------------
// StartServer
// Creates a new process for the server and starts it up.
// -----------------------------------------------------------------------------
//
TInt RMediatorServer::StartServer()
    {
	TInt result( KErrNone );
	// create server - if one of this name does not already exist
	TFindProcess findServerProcess( KMediatorServerProcessName );
	TFullName name;
	if ( findServerProcess.Next( name ) != KErrNone ) // we don't exist already
		{
		TRequestStatus status( KRequestPending );
		RProcess server;
		// Create the server process
		result = server.Create( KMediatorServerExe, KNullDesC );		
		if( result != KErrNone )
			{
			ERROR_TRACE(Print(_L("[Mediator] RMediatorServer::StartServer: result=%d\n"), result ) );
			return result;
			}

		// Process created successfully
		server.Rendezvous( status );
		server.Resume(); // start it going
		
		// Wait until the completion of the server creation
		// server signals us when it's up
		User::WaitForRequest( status );
		if( status != KErrNone )
			{
            ERROR_TRACE(Print(_L("[Mediator] RMediatorServer::StartServer: status=%d\n"), status.Int() ) );
			server.Close();
			return status.Int();
			}
			
		// Server created successfully
		server.Close(); // we can close the handle to server process now
		}
    return result;
    }
Пример #29
0
/* 显示BMP图片 */
static int _DrawBMPFile(char *path)
{
    FRESULT rc;
    uint32_t size;
    FIL fil;
    uint8_t *pFile = (uint8_t*)SRAM_START_ADDRESS;
    UINT br;
    /* 读取文件 */
    rc = f_open(&fil, path, FA_READ);
    ERROR_TRACE(rc);
    if(rc) return 1;
    size = f_size(&fil);
    printf("file size:%d\r\n", size);
    if(size > SRAM_SIZE)
    {
        printf("file size to large\r\n");
        rc = f_close(&fil);
        return 2;
    }
    rc = f_read(&fil, pFile, size, &br);
    if(rc || br != size)
    {
        printf("file data read failed\r\n");
        rc = f_close(&fil);
        return 3;
    }
    printf("Xsize:%d Ysize:%d\r\n", GUI_BMP_GetXSize(pFile), GUI_BMP_GetYSize(pFile));
    GUI_Clear();
    if(GUI_BMP_Draw(pFile, 0, 0))
    {
        GUI_DispString("BMP file display failed!");
    }
    rc = f_close(&fil);
    ERROR_TRACE(rc);
    return 0;
}
Пример #30
0
/*******************************************************************************
  * @函数名称		log_mkdir
  * @函数说明		write log
  * @输入参数		file pointer
  * @输出参数		无
  * @返回参数		文件夹的总数
*******************************************************************************/
uint8_t log_mkdir(uint8_t *dir_name)
{
    FRESULT rc;
    
    uint8_t src[40] = {0};
    
    strcat(src,"0:/");
    
    strcat(src,dir_name);
    
    rc = f_mkdir(src);
    
    ERROR_TRACE(rc);
    
    return true;
}