示例#1
0
文件: update.c 项目: tegoo/legato-af
//--------------------------------------------------------------------------------------------------
static void UpdateProgressHandler
(
    le_update_State_t updateState,   ///< Current State of ongoing update task in Update State
                                     ///< machine.

    uint percentDone,                ///< Percent done for current state. As example: at state
                                     ///< LE_UPDATE_STATE_UNPACKING, percentDone=80 means,
                                     ///< 80% of the update file data is already transferred to
                                     ///< unpack process.

    void* contextPtr                 ///< Context pointer.
)
{
    static const int StatusMsgBytes = 100;
    char statusMsg[StatusMsgBytes];

    switch(updateState)
    {
        // TODO: Currently app/firmware(app script, modemService) tools are not able to give
        // status in the middle of installation. Revise the way of printing when these tools
        // will be able to provide installation status.
        case LE_UPDATE_STATE_NEW:
            // Update started. Print this information.
            fprintf(stdout, "New update started\n");
            break;

        case LE_UPDATE_STATE_UNPACKING:
            // Reset all characters to zero.
            memset(statusMsg, 0, StatusMsgBytes);
            snprintf(statusMsg, sizeof(statusMsg), "Unpacking package");
            // Print progress bar if there is any noticeable progress.
            PrintProgressBar(percentDone, statusMsg);
            break;

        case LE_UPDATE_STATE_APPLYING:
            // Reset all characters to zero.
            memset(statusMsg, 0, StatusMsgBytes);
            snprintf(statusMsg, sizeof(statusMsg), "Applying update");
            // Print progress bar if there is any noticeable progress.
            PrintProgressBar(percentDone, statusMsg);
            break;

        case LE_UPDATE_STATE_SUCCESS:
            //Successful update(install/remove) task.
            fprintf(stdout, "SUCCESS\n");
            le_update_Delete(Handle);
            exit(EXIT_SUCCESS);

        case LE_UPDATE_STATE_FAILED:
            // Failure in update, exit with failure code.
            PrintErrorMsg(le_update_GetErrorCode(Handle));
            fprintf(stderr, "FAILED\n");
            le_update_Delete(Handle);
            exit(EXIT_FAILURE);
    }

}
示例#2
0
SRes ZPatcher::OnProgress(void *p, UInt64 inSize, UInt64 outSize)
{
	ICompressProgressPlus* progress = reinterpret_cast<ICompressProgressPlus*>(p);

	PrintProgressBar((((float)inSize / (float)progress->TotalSize)*100.0f), outSize);

	return SZ_OK;
	/* Returns: result. (result != SZ_OK) means break.
	Value (UInt64)(Int64)-1 for size means unknown value. */
}
示例#3
0
//--------------------------------------------------------------------------------------------------
static void UpdateProgressHandler
(
    le_update_State_t updateState,   ///< Current State of ongoing update task in Update State
                                     ///< machine.

    uint percentDone,                ///< Percent done for current state. As example: at state
                                     ///< LE_UPDATE_STATE_UNPACKING, percentDone=80 means,
                                     ///< 80% of the update file data is already transferred to
                                     ///< unpack process.

    void* contextPtr                 ///< Context pointer.
)
{
    switch(updateState)
    {
        case LE_UPDATE_STATE_UNPACKING:
            // Print progress bar if there is any noticeable progress.
            PrintProgressBar(percentDone, "Unpacking package");
            break;

        case LE_UPDATE_STATE_DOWNLOAD_SUCCESS:
            le_update_Install();
            break;

        case LE_UPDATE_STATE_APPLYING:
            // Print progress bar if there is any noticeable progress.
            PrintProgressBar(percentDone, "Applying update");
            break;

        case LE_UPDATE_STATE_SUCCESS:
            //Successful completion.
            printf("\nSUCCESS\n");
            exit(EXIT_SUCCESS);

        case LE_UPDATE_STATE_FAILED:
            // Failure in update, exit with failure code.
            PrintErrorMsg();
            printf("\nFAILED\n");
            exit(EXIT_FAILURE);
    }
}
示例#4
0
int DownloadFileWriter::TransferInfo(void *p, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
{
	DownloadFileWriter* filewriter = (DownloadFileWriter*)p;
	CURL *curl = filewriter->m_CurlHandle;
	double curtime = 0;

	curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &curtime);

// 	under certain circumstances it may be desirable for certain functionality
// 	to only run every N seconds, in order to do this the transaction time can
// 	be used
// 	if ((curtime - filewriter->m_LastRunTime) >= MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL)
// 	{
// 		filewriter->m_LastRunTime = curtime;
// 		fprintf(stderr, "\r\nTOTAL TIME: %f\n", curtime);
// 	}

	int percentage = (dltotal == 0) ? 0 : (int)(((float)dlnow / (float)dltotal) * 100);

	PrintProgressBar(percentage, dlnow);

	return 0;
}