示例#1
0
static int CacheLoadConfig( module_t *p_module, FILE *file )
{
    uint32_t i_lines;
    uint16_t i_size;

    /* Calculate the structure length */
    LOAD_IMMEDIATE( p_module->i_config_items );
    LOAD_IMMEDIATE( p_module->i_bool_items );

    LOAD_IMMEDIATE( i_lines );

    /* Allocate memory */
    if (i_lines)
    {
        p_module->p_config =
            (module_config_t *)calloc( i_lines, sizeof(module_config_t) );
        if( p_module->p_config == NULL )
        {
            p_module->confsize = 0;
            return VLC_ENOMEM;
        }
    }
    p_module->confsize = i_lines;

    /* Do the duplication job */
    for (size_t i = 0; i < i_lines; i++ )
    {
        LOAD_IMMEDIATE( p_module->p_config[i] );

        LOAD_STRING( p_module->p_config[i].psz_type );
        LOAD_STRING( p_module->p_config[i].psz_name );
        LOAD_STRING( p_module->p_config[i].psz_text );
        LOAD_STRING( p_module->p_config[i].psz_longtext );
        LOAD_STRING( p_module->p_config[i].psz_oldname );

        if (IsConfigStringType (p_module->p_config[i].i_type))
        {
            LOAD_STRING (p_module->p_config[i].orig.psz);
            p_module->p_config[i].value.psz =
                    (p_module->p_config[i].orig.psz != NULL)
                        ? strdup (p_module->p_config[i].orig.psz) : NULL;
        }
        else
            memcpy (&p_module->p_config[i].value, &p_module->p_config[i].orig,
                    sizeof (p_module->p_config[i].value));

        p_module->p_config[i].b_dirty = false;

        if( p_module->p_config[i].i_list )
        {
            if( p_module->p_config[i].ppsz_list )
            {
                int j;
                p_module->p_config[i].ppsz_list =
                    xmalloc( (p_module->p_config[i].i_list+1) * sizeof(char *));
                if( p_module->p_config[i].ppsz_list )
                {
                    for( j = 0; j < p_module->p_config[i].i_list; j++ )
                        LOAD_STRING( p_module->p_config[i].ppsz_list[j] );
                    p_module->p_config[i].ppsz_list[j] = NULL;
                }
            }
            if( p_module->p_config[i].ppsz_list_text )
            {
                int j;
                p_module->p_config[i].ppsz_list_text =
                    xmalloc( (p_module->p_config[i].i_list+1) * sizeof(char *));
                if( p_module->p_config[i].ppsz_list_text )
                {
                  for( j = 0; j < p_module->p_config[i].i_list; j++ )
                      LOAD_STRING( p_module->p_config[i].ppsz_list_text[j] );
                  p_module->p_config[i].ppsz_list_text[j] = NULL;
                }
            }
            if( p_module->p_config[i].pi_list )
            {
                p_module->p_config[i].pi_list =
                    xmalloc( (p_module->p_config[i].i_list + 1) * sizeof(int) );
                if( p_module->p_config[i].pi_list )
                {
                    for (int j = 0; j < p_module->p_config[i].i_list; j++)
                        LOAD_IMMEDIATE( p_module->p_config[i].pi_list[j] );
                }
            }
        }

        if( p_module->p_config[i].i_action )
        {
            p_module->p_config[i].ppf_action =
                xmalloc( p_module->p_config[i].i_action * sizeof(void *) );
            p_module->p_config[i].ppsz_action_text =
                xmalloc( p_module->p_config[i].i_action * sizeof(char *) );

            for (int j = 0; j < p_module->p_config[i].i_action; j++)
            {
                p_module->p_config[i].ppf_action[j] = NULL;
                LOAD_STRING( p_module->p_config[i].ppsz_action_text[j] );
            }
        }
    }

    return VLC_SUCCESS;

 error:

    return VLC_EGENERIC;
}
string UserDefaultUtils::getLevelHighScoreUsername(const char* ID)
{
	return LOAD_STRING(CCString::createWithFormat("%s_HIGHSCORE_USR", ID)->getCString());
}
string UserDefaultUtils::getLastUsedHero()
{
	return LOAD_STRING("HERO_LAST_USED");
}
示例#4
0
#include "MaintenanceCountersDefs.h"
#include "MaintenanceCounters.h"
#include "CSaveTransaction.h"
#include <algorithm>

#ifndef PARAMS_EXP_IMP
#include "FEResources.h"
#else
#define LOAD_STRING(resid)    ""
#define WIZARD_TITLE(_title_) ""
#endif

const char RECOVER_FILE_SIGNATURE[] = "SFPR";

// Machine configuration file names
QString APP_CFG_FILE_NAME = LOAD_STRING(IDS_APP_CFG_FILE_NAME);
QString RECOVER_FILE_NAME = LOAD_STRING(IDS_RECOVER_FILE_NAME);

// Structure for recover binary file
typedef struct {
  ULONG Signature;   // Must be 'SFPR'
  ULONG SliceNum;
  long ZPosition;
  float ModelHeight;
  int LastSliceSizeType;

} TRecoverFileStruct;

// Pointer to the singleton instance (static)
CAppParams *CAppParams::m_AppParamsInstance = NULL;
示例#5
0
BOOL CIBAOutputBar::AddCheckOutLog(COperationInfo& OperationInfo)
{
	CIBAString strTmp;

	BOOL bOK = FALSE;
	switch(OperationInfo.GetOperationType())
	{//结账时间|用户级别|终端号|上机时间|上网账号|姓名|证件号码|金额|备注
	case CIBAGlobal::emOpTypeAutoReturn:
		{
			m_listCheckOut.InsertItem(0, COleDateTime::GetCurrentTime().Format(_T("%H:%M:%S")));
			CString strTmp;
			strTmp = CNetBarConfig::GetInstance()->GetUserClassName(OperationInfo.GetClassId());
			m_listCheckOut.SetItemText(0, 1, strTmp); // 用户级别
			strTmp = OperationInfo.GetNetId();
			m_listCheckOut.SetItemText(0,4, strTmp);

			strTmp = OperationInfo.GetUserName();
			m_listCheckOut.SetItemText(0,5, strTmp);

			strTmp = OperationInfo.GetIdNum();
			m_listCheckOut.SetItemText(0,6, strTmp);

			// 备注显示为自动退款
			m_listCheckOut.SetItemText(0, 8,  CIBAGlobal::GetOperationName(CIBAGlobal::emOpTypeAutoReturn));
		}
		bOK = TRUE;
		break;
	case CIBAGlobal::emOpTypeVipReturn:
		{
			m_listCheckOut.InsertItem(0, COleDateTime::GetCurrentTime().Format(_T("%H:%M:%S")));
			CString strTmp;
			strTmp = CNetBarConfig::GetInstance()->GetUserClassName(OperationInfo.GetClassId());
			m_listCheckOut.SetItemText(0, 1, strTmp); // 用户级别

			strTmp = OperationInfo.GetTermId();
			m_listCheckOut.SetItemText(0, 2, strTmp); // 终端号

			if (CIBAHelpper::IsValidTime(OperationInfo.GetCheckInTime()))
			{
				strTmp = OperationInfo.GetCheckInTime().Format(_T("%H:%M:%S"));
				m_listCheckOut.SetItemText(0, 3, strTmp);
			}

			strTmp = OperationInfo.GetNetId();
			m_listCheckOut.SetItemText(0,4, strTmp);

			strTmp = OperationInfo.GetUserName();
			m_listCheckOut.SetItemText(0,5, strTmp);

			strTmp = OperationInfo.GetIdNum();
			m_listCheckOut.SetItemText(0,6, strTmp);

			m_listCheckOut.SetItemText(0,8, OperationInfo.GetDescription());
			
			bOK = TRUE;
			break;
		}
		
	case CIBAGlobal::emOpTypeRoomReturn:
		{
			m_listCheckOut.InsertItem(0, COleDateTime::GetCurrentTime().Format(_T("%H:%M:%S")));
			CString strTmp;
			strTmp = CNetBarConfig::GetInstance()->GetUserClassName(OperationInfo.GetClassId());
			m_listCheckOut.SetItemText(0, 1, strTmp); // 用户级别

			strTmp = OperationInfo.GetTermId();
			m_listCheckOut.SetItemText(0, 2, strTmp); // 终端号

			if (CIBAHelpper::IsValidTime(OperationInfo.GetCheckInTime()))
			{
				strTmp = LOAD_STRING(IDS_ROOM_OPEN_TIME);
				strTmp += OperationInfo.GetCheckInTime().Format(_T("%H:%M:%S"));
				m_listCheckOut.SetItemText(0, 3, strTmp);
			}

			strTmp = OperationInfo.GetNetId();
			m_listCheckOut.SetItemText(0,4, strTmp);

			strTmp = OperationInfo.GetUserName();
			m_listCheckOut.SetItemText(0,5, strTmp);

			strTmp = OperationInfo.GetIdNum();
			m_listCheckOut.SetItemText(0,6, strTmp);

			m_listCheckOut.SetItemText(0,8, OperationInfo.GetDescription());
			
			bOK = TRUE;
			break;
		}
		
	case CIBAGlobal::emOpTypeReturn:
		{
			m_listCheckOut.InsertItem(0, COleDateTime::GetCurrentTime().Format(_T("%H:%M:%S")));
			CString strTmp;
			strTmp = CNetBarConfig::GetInstance()->GetUserClassName(OperationInfo.GetClassId());
			m_listCheckOut.SetItemText(0, 1, strTmp); // 用户级别

			strTmp = OperationInfo.GetTermId();
			m_listCheckOut.SetItemText(0, 2, strTmp); // 终端号

			if (CIBAHelpper::IsValidTime(OperationInfo.GetCheckInTime()))
			{
				strTmp = OperationInfo.GetCheckInTime().Format(_T("%H:%M:%S"));
				m_listCheckOut.SetItemText(0, 3, strTmp);
			}

			strTmp = OperationInfo.GetNetId();
			m_listCheckOut.SetItemText(0,4, strTmp);

			strTmp = OperationInfo.GetUserName();
			m_listCheckOut.SetItemText(0,5, strTmp);

			strTmp = OperationInfo.GetIdNum();
			m_listCheckOut.SetItemText(0,6, strTmp);


			strTmp.Format(_T("%.2f"), OperationInfo.GetConsumeMoney() / 100.0);
			m_listCheckOut.SetItemText(0,7, strTmp);

			CString strDescription;

			// IDS_OPTYPE_BALANCE: "余额:%.2f"
			// IDS_OPTYPE_BALANCE_EX: "余额:%.2f + 押金:%.2f"
			if (OperationInfo.GetDeposit() > 0)
			{
				strDescription.Format(LOAD_STRING(IDS_OPTYPE_BALANCE_EX),
					OperationInfo.GetOperationAmount() / 100.0,
					OperationInfo.GetDeposit() / 100.0);
			}
			else
			{
				strDescription.Format(LOAD_STRING(IDS_OPTYPE_BALANCE),
					OperationInfo.GetOperationAmount() / 100.0);
			}

			if (!OperationInfo.GetDescription().IsEmpty())
			{
				if (!strDescription.IsEmpty())
				{
					strDescription.Append(_T(","));
				}

				strDescription.Append(OperationInfo.GetDescription());
			}

			m_listCheckOut.SetItemText(0, 8, strDescription);
		}
		bOK = TRUE;
		break;
	}

	if (bOK)
		SaveToFile( lpFileNameSuffix[LIST_CHECKOUT], *lpListCtrl[LIST_CHECKOUT]);

	return FALSE;
}
示例#6
0
void CMainFrame::StartIBA()
{
	UNIT_AUTO_TRACE("CMainFrame::StartIBA()--");

	CIBALog::GetInstance()->Write(_T("StartIBA"));
	
	if (0 == CNetBarConfig::GetInstance()->GetIsShowRzxPhoto())
	{
		m_wndTaskPane.RemoveGroup(2);
		m_wndTaskPane.m_dlgUserPhoto.ShowWindow(SW_HIDE);
	}
	

	// 2011/05/17-gxx: 例如账户直充的控制配置是在Menubar创建后读取的,添加代码让菜单重新设置
	m_wndMenuBar.ResetAll();

	
	CLocalServer::GetInstance()->ConnectServer();
	CLocalServer::GetInstance()->ActiveMemberList.LoadFromDB();
	CLocalServer::GetInstance()->GetActiveMemberView()->Refresh(TRUE);
	

	CString strTmp;
	//GetWindowText(strTmp);
	// 2011/08/24-8201-gxx: 
	strTmp = LOAD_STRING(IDS_IBATITLE);

	strTmp.Insert(0, _T(" - "));
	strTmp.Insert(0, CNetBarConfig::GetInstance()->GetNetBarName());
	SetWindowText(strTmp);

	ShowWindow(SW_SHOWMAXIMIZED);
	UpdateWindow();
	UpdateStatusText();

	EmptyWorkingSet(GetCurrentProcess);

	//初始化实名系统
	if (!theApp.GetRealName()->InitRealName())
	{
		theApp.IBAMsgBox(_T("初始化实名认证失败"));
		CBCGPFrameWnd::OnClose();

	}
	else
	{
		SetTimer(1000, 1000 * 10, NULL); //10秒一次

		// 2011/05/05-gxx: 开启获取滚动文字
		m_wndFastLane.StartThread();
	}

	CJuBao* pTmp = NULL;

	// 2013-9-11-qscadd:聚宝接口初始化
	if(1 == CNetBarConfig::GetInstance()->GetEnableJuBao())
	{
		if(!m_pJuBao)
		{
			m_pJuBao = new CJuBao;
		}
		if(!m_pJuBao->RegCallBackFunc())
		{
			AfxMessageBox(_T("聚宝注册初始化失败!"));
			IBA_LOG0(_T("注册聚宝回调函数失败!"));
		}
		if(!m_pJuBao->InitInterface("testxzg001","610","sntestxzg001"))
		{
			AfxMessageBox(_T("聚宝初始化失败!"));
			IBA_LOG0(_T("聚宝初始化失败!"));
		}
		pTmp = GetJubaoInf();
	}

	if (CNetBarConfig::GetInstance()->GetEnableID2Reader())
	{
		HANDLE hMutex = ::CreateMutex(NULL, FALSE, _T("_ID2READER_ALLOW_MUTEX_"));
		if(hMutex == NULL)
			return;

		if(GetLastError() != ERROR_ALREADY_EXISTS)
		{
			WinExec(".\\IBABin\\ID2Reader.exe", SW_HIDE);
		}
		else
		{
			CloseHandle(hMutex);
		}
	}
	else
	{
		// 空白照片删除 QSC 2013-5-7 10:46:16
		//m_wndTaskPane.RemoveGroup(2);
		//m_wndTaskPane.m_dlgUserPhoto.ShowWindow(SW_HIDE);
	}
}
示例#7
0
BOOL CDlgIBAFastlane::OnEraseBkgnd(CDC* pDC)
{
	CRect rcRect;
	GetClientRect( rcRect );

	CDC memDC;  // Paint的内存DC
	CBitmap bmp;

	bmp.CreateCompatibleBitmap( pDC,rcRect.Width(),rcRect.Height() );
	memDC.CreateCompatibleDC(NULL);
	memDC.SelectObject(&bmp);

	CBCGPToolBar* pParent = (CBCGPToolBar*)GetParent();
	if( pParent )
	{
		
		WINDOWPLACEMENT wp;
		this->GetWindowPlacement(&wp);

		CRect rcParent;
		pParent->GetClientRect(rcParent);

		// 绘制背景
		CDC memParentDC;
		CBitmap bmpParent;
		bmpParent.CreateCompatibleBitmap(pDC,rcParent.Width(),rcParent.Height());
		memParentDC.CreateCompatibleDC(NULL);
		memParentDC.SelectObject(&bmpParent);

		CDC* pParentDC = pParent->GetDC();
		CBCGPVisualManager::GetInstance ()->OnFillBarBackground (&memParentDC, pParent,
			rcParent,rcParent);
		pParent->ReleaseDC(pParentDC);

		CRect rt = wp.rcNormalPosition;

		memDC.BitBlt(0,0,rcRect.Width(),rcRect.Height(),&memParentDC,wp.rcNormalPosition.left,wp.rcNormalPosition.top,
			SRCCOPY);

		pDC->BitBlt(0,0,rt.Width(),rt.Height(),&memDC,0,0,SRCCOPY);
	}

	CBitmap bmpImg;
	BOOL bRes = 0;
	if (m_bBugleActive)
	{
		bRes = bmpImg.LoadBitmap(IDB_BUGLE2);
	}
	else
	{
		bRes = bmpImg.LoadBitmap(IDB_BUGLE1);
	}
	if (bRes)
	{
		BITMAP bt;
		bmpImg.GetBitmap(&bt);

		CStatic *pStc = (CStatic*)GetDlgItem(IDC_PIC_BUGLE);

		CDC memDC;
		memDC.CreateCompatibleDC(pDC);
		memDC.SelectObject(&bmpImg);

		CRect rc;
		pStc->GetClientRect(rc);
		WINDOWPLACEMENT wp;
		pStc->GetWindowPlacement(&wp);

		CRect rcClient;
		GetClientRect(rcClient);

		rc.left = wp.rcNormalPosition.left;
		rc.top = rcClient.top + (rcClient.Height()-bt.bmHeight)/2;
		rc.right = rc.left + bt.bmWidth;
		rc.bottom = rc.top + bt.bmHeight;

		pDC->TransparentBlt(rc.left,rc.top,rc.Width(),rc.Height(),&memDC,0,0,rc.Width(),rc.Height(),RGB(255,255,255));
	}
	else
	{
		IBA_ASSERT2(0,"喇叭image 问题");
	}

	{
		WINDOWPLACEMENT pm;
		m_stcPicStatus.GetWindowPlacement(&pm);

		int nWidth = 85;
		int nHeight = 21;
		int nStatus = m_nIBAStatus;

		int nX = pm.rcNormalPosition.left;
		int nY = pm.rcNormalPosition.top;
		int nImgX = nStatus * nWidth;
		int nImgY = 0;
		
		BOOL bRes = m_imgStatus.Draw(pDC->GetSafeHdc(), nX, nY, nWidth, nHeight, nImgX, nImgY, nWidth, nHeight);
		pDC->SetBkMode(TRANSPARENT);
		CFont* pOldFont = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT);
		CStringArray strArr;
		CIBAHelpper::SplitLine(LOAD_STRING(IDS_IBA_NET_STATUS),strArr);
		CRect rcTest(0,0,0,0);
		CString strText = strArr.GetAt(nStatus);
		pDC->DrawText(strText,rcTest,DT_CALCRECT);
		CRect rcTxt;
		rcTxt.left = nX;
		rcTxt.right = nX + nWidth;
		rcTxt.top = nY + (nHeight - rcTest.Height())/2;
		rcTxt.bottom = rcTxt.top + rcTest.Height();
		pDC->DrawText(strText,rcTxt,DT_CENTER);
		bRes = bRes;
		pDC->SelectObject(pOldFont);
	}
	//return CBCGPDialog::OnEraseBkgnd(pDC);
	return TRUE;
}
示例#8
0
文件: cache.c 项目: 0xheart0/vlc
static int CacheLoadConfig (module_config_t *cfg, FILE *file)
{
    LOAD_IMMEDIATE (cfg->i_type);
    LOAD_IMMEDIATE (cfg->i_short);
    LOAD_FLAG (cfg->b_advanced);
    LOAD_FLAG (cfg->b_internal);
    LOAD_FLAG (cfg->b_unsaveable);
    LOAD_FLAG (cfg->b_safe);
    LOAD_FLAG (cfg->b_removed);
    LOAD_STRING (cfg->psz_type);
    LOAD_STRING (cfg->psz_name);
    LOAD_STRING (cfg->psz_text);
    LOAD_STRING (cfg->psz_longtext);
    LOAD_IMMEDIATE (cfg->list_count);

    if (IsConfigStringType (cfg->i_type))
    {
        LOAD_STRING (cfg->orig.psz);
        if (cfg->orig.psz != NULL)
            cfg->value.psz = strdup (cfg->orig.psz);
        else
            cfg->value.psz = NULL;

        if (cfg->list_count)
            cfg->list.psz = xmalloc (cfg->list_count * sizeof (char *));
        else /* TODO: fix config_GetPszChoices() instead of this hack: */
            LOAD_IMMEDIATE(cfg->list.psz_cb);
        for (unsigned i = 0; i < cfg->list_count; i++)
        {
            LOAD_STRING (cfg->list.psz[i]);
            if (cfg->list.psz[i] == NULL /* NULL -> empty string */
             && (cfg->list.psz[i] = calloc (1, 1)) == NULL)
                goto error;
        }
    }
    else
    {
        LOAD_IMMEDIATE (cfg->orig);
        LOAD_IMMEDIATE (cfg->min);
        LOAD_IMMEDIATE (cfg->max);
        cfg->value = cfg->orig;

        if (cfg->list_count)
            cfg->list.i = xmalloc (cfg->list_count * sizeof (int));
        else /* TODO: fix config_GetPszChoices() instead of this hack: */
            LOAD_IMMEDIATE(cfg->list.i_cb);
        for (unsigned i = 0; i < cfg->list_count; i++)
             LOAD_IMMEDIATE (cfg->list.i[i]);
    }
    cfg->list_text = xmalloc (cfg->list_count * sizeof (char *));
    for (unsigned i = 0; i < cfg->list_count; i++)
    {
        LOAD_STRING (cfg->list_text[i]);
        if (cfg->list_text[i] == NULL /* NULL -> empty string */
         && (cfg->list_text[i] = calloc (1, 1)) == NULL)
            goto error;
    }

    return 0;
error:
    return -1; /* FIXME: leaks */
}
示例#9
0
文件: cache.c 项目: 0xheart0/vlc
static module_t *CacheLoadModule (FILE *file)
{
    module_t *module = vlc_module_create (NULL);
    if (unlikely(module == NULL))
        return NULL;

    /* Load additional infos */
    LOAD_STRING(module->psz_shortname);
    LOAD_STRING(module->psz_longname);
    LOAD_STRING(module->psz_help);

    LOAD_IMMEDIATE(module->i_shortcuts);
    if (module->i_shortcuts > MODULE_SHORTCUT_MAX)
        goto error;
    else
    {
        module->pp_shortcuts =
            xmalloc (sizeof (*module->pp_shortcuts) * module->i_shortcuts);
        for (unsigned j = 0; j < module->i_shortcuts; j++)
            LOAD_STRING(module->pp_shortcuts[j]);
    }

    LOAD_STRING(module->psz_capability);
    LOAD_IMMEDIATE(module->i_score);
    LOAD_IMMEDIATE(module->b_unloadable);

    /* Config stuff */
    if (CacheLoadModuleConfig (module, file) != VLC_SUCCESS)
        goto error;

    LOAD_STRING(module->domain);
    if (module->domain != NULL)
        vlc_bindtextdomain (module->domain);

    uint32_t submodules;
    LOAD_IMMEDIATE(submodules);

    for (; submodules > 0; submodules--)
    {
        module_t *submodule = vlc_module_create (module);

        free (submodule->pp_shortcuts);
        LOAD_STRING(submodule->psz_shortname);
        LOAD_STRING(submodule->psz_longname);

        LOAD_IMMEDIATE(submodule->i_shortcuts);
        if (submodule->i_shortcuts > MODULE_SHORTCUT_MAX)
            goto error;
        else
        {
            submodule->pp_shortcuts =
                xmalloc (sizeof (*submodule->pp_shortcuts) * submodule->i_shortcuts);
            for (unsigned j = 0; j < submodule->i_shortcuts; j++)
                LOAD_STRING(submodule->pp_shortcuts[j]);
        }

        LOAD_STRING(submodule->psz_capability);
        LOAD_IMMEDIATE(submodule->i_score);
    }

    return module;
error:
    vlc_module_destroy(module);
    return NULL;
}
示例#10
0
int TCartridgeErrorForm::OpenCartridgeErrorDialog(int DlgType, TChamberIndex Chamber)
{
	if(!VALIDATE_CHAMBER_INCLUDING_WASTE(Chamber))
		return 0;

	m_Chamber = Chamber;
	m_DlgType = DlgType;

	m_SecondsCounter = 0;
	m_MinutesCounter = 0;
	m_HoursCounter   = 0;

	QString tmp;

	int i = FIRST_TANK_INCLUDING_WASTE_TYPE;

	//Add first cartridge string
	try
	{
		// Following while may throw the exception if there's no tank associated with 'Chamber'.
		while(m_BackEndInterface->IsChambersTank(Chamber, i) == false)
		{
			if(i>=LAST_TANK_INCLUDING_WASTE_TYPE)
				throw EQException(QFormatStr("No tank is associated with M%d chamber.", Chamber));
			i++;
		}
		// Showing an "MRW was not completed" error-dialog is done at the catch block below.
		// (identified by a segment with "UNDEFINED" material)
		/*if (TYPE_CHAMBER_WASTE != m_Chamber)
		  if (QString(CAppParams::Instance()->TypesArrayPerPipe[(TTankIndex)i]).compare("UNDEFINED") == 0)
			throw EQException("MRW was not completed"); */

		if(TYPE_CHAMBER_WASTE == m_Chamber)
		{
			tmp = TankToStr((TTankIndex)i) + " cartridge"; // cartridge in "singular".

			if(DlgType == FE_INSERT_CARTRIDGE)
			{
				ErrorLabel->Caption = "Waste cartridge removal has been detected";
				tmp = "insert " + tmp;
			}
			else
			{
				ErrorLabel->Caption = "Waste cartridge is full";
				tmp = "empty " + tmp;
			}
		}
		else
		{
			int AssociatedCartridges = CAppParams::Instance()->CartridgeRedundancy+1; //Num of cartridges associated to chamber
			QString ChamberMaterial = CAppParams::Instance()->TypesArrayPerChamber[m_Chamber];
			bool AdditionalMaterial = false;
			//Create the string with the relevant cartridges
			for(int t=0; t<AssociatedCartridges && i<LAST_TANK_INCLUDING_WASTE_TYPE; t++,i++)
			{
				//check that the cartridge has the same material as the its chamber
				if(ChamberMaterial.compare(CAppParams::Instance()->TypesArrayPerPipe[i]) == 0)
				{
					if(m_BackEndInterface->IsChambersTank(Chamber, i))
					{
						if(!AdditionalMaterial) //first entrance
						{
							tmp = TankToStr((TTankIndex)i);
							AdditionalMaterial = true;
						}
						else
							tmp+= " and/or " + TankToStr((TTankIndex)i);
					}
				}
			}
			tmp = tmp + " cartridge(s)"; // cartridge in "plural".
			ErrorLabel->Caption         = (QString(CAppParams::Instance()->TypesArrayPerChamber[m_Chamber]) + " Material Required").c_str();
			tmp = ((FE_INSERT_CARTRIDGE == DlgType) ? "Insert " : "Replace ") + tmp;
		}
		InstructionsLabel->Caption    = QFormatStr("%s\nor press 'Stop' to terminate printing",tmp.c_str()).c_str();
	}
	catch(EQException& Exception)
	{
		ErrorLabel->Caption = "No cartridge may be used";
		InstructionsLabel->Caption = Exception.GetErrorMsg().c_str();
	}
	catch(...)
	{
		ErrorLabel->Caption = "No cartridge may be used";
		InstructionsLabel->Caption = QFormatStr(LOAD_STRING(IDS_NOT_COMPLETED), WIZARD_TITLE(IDS_RR_WIZARD), StopButton->Caption.c_str(), WIZARD_TITLE(IDS_RR_WIZARD)).c_str();
	}

	this->Caption = "Elapsed Time 00:00:00";
	ErrorLabel->Width             = this->Width;
	ErrorLabel->Left              = 0;
	InstructionsLabel->Width      = this->Width;
	InstructionsLabel->Left       = 0;
	CartridgeStatusTimer->Enabled = true;
	CartridgeStatusTimer->Interval = 500;  // should be >= DELAY_BETWEEN_EACH_OCB_STATUS_VERIFICATION_MIL  that is defined in OCBStatus.cpp
	ElapsedTimeTimer->Enabled     = true;
	m_ReadyForPrint               = false;
	m_TanksStatus.clear();

	for(int t = FIRST_TANK_TYPE; t < LAST_TANK_TYPE; t++)
		if(m_BackEndInterface->IsChambersTank(m_Chamber, t))
			m_TanksStatus[(TTankIndex)t] = TANK_OUT;

	UpdateTanksState();

	//window is already opened
	if(Visible)  //bug 5954
		return 0;

	if(m_Modal)
	{
		return ShowModal();
	}
	else
	{
		Show();
		return Q_NO_ERROR;
	}
}
示例#11
0
/*************************************************
Function:       // ShowUserInfo
Description:    //
Calls:          //
Table Accessed: //
Table Updated:  //
Input:          //
                //
Output:         //
Return:         //
Others:         //
*************************************************/
void CIBATaskPane::ShowUserInfo(CActiveMember & ActiveMember)
{
	CString strContent;
	
	CString strUseTime = ActiveMember.GetCheckInTimeAsString();
	if (!strUseTime.IsEmpty())
	{
		strUseTime.AppendFormat(_T("(%s)"), ActiveMember.GetPayTypeAsString());
	}

		/*L"姓名:%s\r\n"
		L"账号:%s\r\n"
		L"用户级别:%s\r\n"
		L"证件号码:%s\r\n"
		L"\r\n"
		L"\r\n"
		L"电脑名称:%s\r\n"
		L"机器区域:%s\r\n"

		L"使用时间:%s\r\n"
		L"使用时长:%s\r\n"
		L"\r\n"
		L"\r\n"
		L"可用金额:%s\r\n"
		L"消费金额:%s\r\n",*/

	strContent.Format(LOAD_STRING(IDS_TASK_INFO),
		ActiveMember.GetUserName(),
		ActiveMember.GetNetId(),
		ActiveMember.GetUserClassName(),
		ActiveMember.GetPersonalID(),
		ActiveMember.GetTerminalID(),
		ActiveMember.GetPCClass(),
		strUseTime,
		ActiveMember.GetUseTimeAsString(),
		ActiveMember.GetAvailavleBalanceAsString(),
		ActiveMember.GetAmountAsString());

	m_ActiveMember = ActiveMember;

	ShowUserInfo(strContent);

	// GXX 2013-5-6 15:20:36 这段代码可能有用,不要删除
	/*if (CNetBarConfig::GetInstance()->GetEnableID2Reader())
	{
		if (m_dlgUserPhoto.m_hWnd == NULL)
		{
			CString strTmp = _T("证件照");
			int nPage1Gr4 = AddGroup(1, strTmp);
			m_dlgUserPhoto.Create(IDD_DLG_USER_PHOTO, this);
			AddWindow(nPage1Gr4, m_dlgUserPhoto, 150);
		}
		CString strPath = theApp.GetWorkPath();
		CString strImgPath = strPath + _T("\\IDImages\\");
		CString strPicPath = strImgPath;
		strPicPath.Append(ActiveMember.GetPersonalID());
		strPicPath.Append(_T(".jpg"));
		if (IsWindow(m_dlgUserPhoto.m_hWnd))
		{
			m_dlgUserPhoto.m_staticPhoto.ShowPic(strPicPath);
		}
	}*/
	if (1 == CNetBarConfig::GetInstance()->GetIsShowRzxPhoto())
	{
		if (m_dlgUserPhoto.m_hWnd == NULL)
		{
			CString strTmp = _T("证件照");
			int nPage1Gr4 = AddGroup(1, strTmp);
			m_dlgUserPhoto.Create(IDD_DLG_USER_PHOTO, this);
			AddWindow(nPage1Gr4, m_dlgUserPhoto, 150);
		}
		CString strPath = theApp.GetWorkPath();
		CString strImgPath = strPath + _T("\\UserImages\\");
		CString strPicPath = strImgPath;
		CString strID = CIBAHelpper::FormatNetId(ActiveMember.GetNetId());
		strPicPath.Append(strID);
		strPicPath.Append(_T(".jpg"));
		if (IsWindow(m_dlgUserPhoto.m_hWnd))
		{
			IBA_LOG(_T("实名照片路径:%s"), strPicPath);
			m_dlgUserPhoto.m_staticPhoto.ShowPic(strPicPath);
		}
	}
}
示例#12
0
void CComputerListView::OnClientShortMessage(SHORT_MESSAGE_INFO& shortMsgInfo)
{	
	//{ 2011/11/15-8210-gxx: 

	CString str = CA2T(shortMsgInfo.shortMsg.message);

	int nSpl = str.Find(_T('|'));
	if (nSpl > 0 && str.Left(nSpl).CompareNoCase(_T("p-ddnparam")) == 0)
	{
		// 购买点卡的消息
		CString strTmp(CA2T(shortMsgInfo.shortMsg.message));
		strTmp = strTmp.Mid(11);

		CString strTerm(CA2T(shortMsgInfo.shortMsg.termID));
		if (strTmp.Find(_T('?')) >= 0)
		{
			strTmp.AppendFormat(_T("&TermId=%s"), strTerm);
		}
		else
		{
			strTmp.AppendFormat(_T("?TermId=%s"), strTerm);
		}

		CActiveMember ActiveMember;
		if (CLocalServer::GetInstance()->ActiveMemberList.GetActiveMember(shortMsgInfo.shortMsg.memberID,ActiveMember))
		{
			strTmp.AppendFormat(_T("&UserName=%s"), ActiveMember.GetUserName());
		}
		else
		{
			strTmp += _T("&UserName=未知姓名");
		}

		IBA_LOG(_T("客户端请求购买点卡,URL=%s"), strTmp);

		CCashierHelper::CashSellDianka(strTmp);
	}

	//}
	else if (shortMsgInfo.shortMsg.messageType !=2 ) // 非余额不足消息
	{
		//弹出式
		CBCGPPopupWindow* pPopup = new CMsgPopupWindow; //这里不需要删除,框架会自动删除的

		// Create indirect:
		CBCGPPopupWndParams params;//设置窗口参数

		CString strMsg, strTermId, strTermIP, strTmp;

		strTermId = CA2W(shortMsgInfo.shortMsg.termID);//终端ID

		// 2011/06/17-gxx: 打补丁,IP长度等于15时,拷贝字符串出问题
		char IP[LEN_IPADDR+1];
		memcpy(IP, shortMsgInfo.shortMsg.computerIP, LEN_IPADDR);
		IP[LEN_IPADDR] = '\0';
		strTermIP = CA2W(IP);//终端IP

		strTermId.Trim();
		strTermIP.Trim();

		if (!strTermIP.IsEmpty())//IP 不是空 表示是客户端信息
		{
			strTmp = LOAD_STRING(IDS_CLIENTINFO);
			strMsg.Format(LOAD_STRING(IDS_FORMTERMIP), strTermId, strTermIP);//设置终端的URL
			params.m_nURLCmdID = (UINT)CLocalServer::GetInstance()->ComputerList.Find(strTermId, strTermIP);
			params.m_hIcon = AfxGetApp()->LoadIcon(IDR_UDO);
		}
		else
		{
			params.m_nURLCmdID = 10000;
			strTmp = LOAD_STRING(IDS_CASHIERINFO);
			params.m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
		}

		//接受客户端消息
		strMsg.Append(CA2W(shortMsgInfo.shortMsg.message));

		params.m_strText = strMsg;

		RECT rt = {-1, -1, -1, -1};

		if (CIBAConfig::GetInstance()->GetMsgLeftBottom())// 从左下角弹出
		{
			SystemParametersInfo(SPI_GETWORKAREA, 0, &rt, 0);
		}

		if (!CIBAConfig::GetInstance()->GetMsgAutoHide())
		{
			pPopup->SetAutoCloseTime(0);
		}

		pPopup->Create(NULL, params, 0, CPoint(rt.left, rt.bottom));//创建窗体

		pPopup->SetWindowText(strTmp);//显示消息

	}

	CClientShortMessage csm;
	csm.SetMemberId( shortMsgInfo.shortMsg.memberID);
	csm.SetMsgBody( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.message));
	csm.SetMsgID( shortMsgInfo.shortMsg.ID);
	csm.SetMsgType( shortMsgInfo.shortMsg.messageType);
	csm.SetRevTime( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.sendTime));
	csm.SetTermID( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.termID));
	csm.SetTermIP( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.computerIP));

	if (csm.GetMsgType() == 2)
	{
		if (CNetBarConfig::GetInstance()->GetReminderBalance())
		{
			static DWORD nTimeCount = GetTickCount() - 10000;
			if (GetTickCount()-nTimeCount > 10000)// 防止在10秒连续播放
			{
				NS_TTS::CIBATTS::GetInstance()->SpeakReminderBalance(csm.GetTermID());
				nTimeCount = GetTickCount();
			}
			
		}
		csm.SetMsgBody(LOAD_STRING(IDS_BALANCE_REMINDER)); // 余额不足
	}

	//写到信息对话框中
	//((CMainFrame*)AfxGetMainWnd())->m_wndOutput.UpdateMsgLog();
	((CMainFrame*)AfxGetMainWnd())->m_wndOutput.AddMsgLog(csm);
}
示例#13
0
/////////////////////////////////////////////////////////////////////////////
// CIBAOutputBar message handlers
//创建
int CIBAOutputBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CBCGPDockingControlBar::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	EnableGripper(FALSE);//不显示标题CAPTION

	CRect rectDummy;
	rectDummy.SetRectEmpty();

	// Create tabs window:
	if (!m_wndTabs.Create(CBCGPTabWnd::STYLE_3D_ONENOTE, rectDummy, this, 1))
	{
		TRACE0("Failed to create output tab window\n");
		return -1;      // fail to create
	}

	m_wndTabs.EnableTabSwap(FALSE);//禁止TAB窗体的拖动功能

	lpListCtrl[0] = &m_wndListInfo;
	lpListCtrl[1] = &m_wndListActive;
	lpListCtrl[2] = &m_listCheckOut;
	lpListCtrl[3] = &m_wndConsumeInfo;
	lpListCtrl[4] = &m_wndMsgInfo;

	if (!CreateOperationList())
	{
		return -1;
	}

 	if (!CreateActiveList())
 	{
 		return -1;
 	}

	// 2011/10/17-8206-gxx: 
	if (!CreateCheckOutList())
	{
		return -1;
	}

	if (!CreateMsgList())
	{
		return -1;
	}

	if (!CreateConsumeList())
	{
		return -1;
	}
	
	m_wndTabs.AddTab(&m_wndListInfo, LOAD_STRING(IDS_OPERATELOG));//添加操作信息页
	m_wndTabs.AddTab(&m_wndListActive, LOAD_STRING(IDS_ACTIVELOG));//添加激活记录页
	m_wndTabs.AddTab(&m_listCheckOut, LOAD_STRING(IDS_CHECKOUT_RECORD)); // 结账记录
	m_wndTabs.AddTab(&m_wndConsumeInfo, LOAD_STRING(IDS_RETURNLOG));//退款
	m_wndTabs.AddTab(&m_wndMsgInfo, LOAD_STRING(IDS_CLIENTINFO));//添加用户信息
	
	m_wndTabs.RecalcLayout();
	m_wndTabs.SetActiveTab(0);
	
	


	return 0;
}
示例#14
0
void CIBAOutputBar::AddOperationLog(COperationInfo& OperationInfo)
{
	CIBAString strTmp;

	m_wndListInfo.InsertItem(0, COleDateTime::GetCurrentTime().Format(_T("%H:%M:%S")));

	
	switch (OperationInfo.GetOperationType())
	{
	case 0://无
		{
			if (OperationInfo.GetIsBundTime())
			{
				m_wndListInfo.SetItemText(0, 1, CIBAGlobal::GetOperationName(CIBAGlobal::emOpTypeBundleTime));
				m_wndListInfo.SetItemText(0, 2, OperationInfo.GetUserName());
				m_wndListInfo.SetItemText(0, 3, FormatNetId(OperationInfo.GetNetId()));
				
				strTmp.Format(_T("%.2f"), OperationInfo.GetOperationAmount() / 100.0);
				m_wndListInfo.SetItemText(0, 4, strTmp);

			}
		}

	case CIBAGlobal::emOpTypeOpen://开户
	case CIBAGlobal::emOpTypeCredit://充值
	case CIBAGlobal::emOpTypeCreditDelete://冲正
	case CIBAGlobal::emOpTypeLocalCredit: // 2011/08/01-8201-gxx: 本地充值
	case CIBAGlobal::emOpTypeCreditModify: // 修改充值
	case CIBAGlobal::emOpTypeChangeMachine://换机
		{
			m_wndListInfo.SetItemText(0,1,CIBAGlobal::GetOperationName(OperationInfo.GetOperationType()));
			SetCreditInfo(OperationInfo);
			break;
		}
	case CIBAGlobal::emOpTypeVipReturn: //会员结账
	case CIBAGlobal::emOpTypeBrokenReturnVip: // 会员断网结账
	case CIBAGlobal::emOpTypeRoomReturn:
		{
			m_wndListInfo.SetItemText(0, 1,CIBAGlobal::GetOperationName(OperationInfo.GetOperationType()));
			
			m_wndListInfo.SetItemText(0, 2, OperationInfo.GetUserName());
			m_wndListInfo.SetItemText(0, 3, OperationInfo.GetNetId());

			CString strDescription;

			if (!OperationInfo.GetDescription().IsEmpty())
			{
				if (!strDescription.IsEmpty())
				{
					strDescription.Append(_T(","));
				}

				strDescription.Append(OperationInfo.GetDescription());
			}

			m_wndListInfo.SetItemText(0, 5, strDescription);

			break;
		}
	
	case CIBAGlobal::emOpTypeReturn: //退款
	case CIBAGlobal::emOpTypeAutoReturn: //自动退款
	case CIBAGlobal::emOpTypeReturnBalance: //退余额
	case CIBAGlobal::emOpTypeLocalReturn: // 本地用户退款
	case CIBAGlobal::emOpTypeBrokenReturn: // 断网退款
		{
			m_wndListInfo.SetItemText(0, 1, CIBAGlobal::GetOperationName(OperationInfo.GetOperationType()));

			m_wndListInfo.SetItemText(0, 2, OperationInfo.GetUserName());
			m_wndListInfo.SetItemText(0, 3, FormatNetId(OperationInfo.GetNetId()));

			strTmp.Format(_T("%.2f"), OperationInfo.GetAllAmount() / 100.0);
			m_wndListInfo.SetItemText(0, 4, strTmp);

			CString strDescription;

			// IDS_OPTYPE_BALANCE: "余额:%.2f"
			// IDS_OPTYPE_BALANCE_EX: "余额:%.2f + 押金:%.2f"
			if (OperationInfo.GetDeposit() > 0)
			{
				strDescription.Format(LOAD_STRING(IDS_OPTYPE_BALANCE_EX),
					OperationInfo.GetOperationAmount() / 100.0,
					OperationInfo.GetDeposit() / 100.0);
			}
			else
			{
				strDescription.Format(LOAD_STRING(IDS_OPTYPE_BALANCE),
					OperationInfo.GetOperationAmount() / 100.0);
			}

			if (!OperationInfo.GetDescription().IsEmpty())
			{
				if (!strDescription.IsEmpty())
				{
					strDescription.Append(_T(","));
				}

				strDescription.Append(OperationInfo.GetDescription());
			}

			m_wndListInfo.SetItemText(0, 5, strDescription);

			break;
		}
	case CIBAGlobal::emOpTypeOpenLocal:// 本地开户
		{
			m_wndListInfo.SetItemText(0, 1, CIBAGlobal::GetOperationName(CIBAGlobal::emOpTypeOpenLocal)); 

			strTmp.LoadString(IDS_LOCALUSER);
			OperationInfo.SetDescription(strTmp);  // 显示本地用户备注
			SetCreditInfo(OperationInfo);
			break;
		}

	case CIBAGlobal::emOpTypeBundleTime://包时
		{
			m_wndListInfo.SetItemText(0, 1, CIBAGlobal::GetOperationName(CIBAGlobal::emOpTypeBundleTime));
			m_wndListInfo.SetItemText(0, 2, OperationInfo.GetUserName());
			m_wndListInfo.SetItemText(0, 3, OperationInfo.GetNetId());

			strTmp.Format(_T("%.2f"), OperationInfo.GetOperationAmount() / 100.0);
			m_wndListInfo.SetItemText(0, 4, strTmp);

			m_wndListInfo.SetItemText(0, 5, OperationInfo.GetDescription());

			break;
		}
	default:
		IBA_ASSERT2(FALSE,"未知的操作类型");
		break;
	}

	INT nType = OperationInfo.GetOperationType();

	if (OperationInfo.GetOperationType() == 2 && 
		CIBAGlobal::NetworkStatus != CIBAGlobal::emNetworkBroken &&
		OperationInfo.GetIsResumeData() == FALSE)
	{
		OperationInfo.SetOperationType(0);
		OperationInfo.SetIsMember(FALSE); //退款的肯定是非会员
		QueryConsume(OperationInfo, TRUE);
	}
	else
	{
		m_wndTabs.SetActiveTab(0);
	}

	// 保存到文件
	SaveToFile( lpFileNameSuffix[LIST_OPERATION], *lpListCtrl[LIST_OPERATION]);
}
示例#15
0
/**
 * Loads a plugins cache file.
 *
 * This function will load the plugin cache if present and valid. This cache
 * will in turn be queried by AllocateAllPlugins() to see if it needs to
 * actually load the dynamically loadable module.
 * This allows us to only fully load plugins when they are actually used.
 */
size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t ***r )
{
    char *psz_filename;
    FILE *file;
    int i_size, i_read;
    char p_cachestring[sizeof(CACHE_STRING)];
    size_t i_cache;
    int32_t i_file_size, i_marker;

    assert( dir != NULL );

    *r = NULL;
    if( asprintf( &psz_filename, "%s"DIR_SEP CACHE_NAME, dir ) == -1 )
        return 0;

    msg_Dbg( p_this, "loading plugins cache file %s", psz_filename );

    file = vlc_fopen( psz_filename, "rb" );
    if( !file )
    {
        msg_Warn( p_this, "cannot read %s (%m)",
                  psz_filename );
        free( psz_filename );
        return 0;
    }
    free( psz_filename );

    /* Check the file size */
    i_read = fread( &i_file_size, 1, sizeof(i_file_size), file );
    if( i_read != sizeof(i_file_size) )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache "
                  "(too short)" );
        fclose( file );
        return 0;
    }

    fseek( file, 0, SEEK_END );
    if( ftell( file ) != i_file_size )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache "
                  "(corrupted size)" );
        fclose( file );
        return 0;
    }
    fseek( file, sizeof(i_file_size), SEEK_SET );

    /* Check the file is a plugins cache */
    i_size = sizeof(CACHE_STRING) - 1;
    i_read = fread( p_cachestring, 1, i_size, file );
    if( i_read != i_size ||
        memcmp( p_cachestring, CACHE_STRING, i_size ) )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache" );
        fclose( file );
        return 0;
    }

#ifdef DISTRO_VERSION
    /* Check for distribution specific version */
    char p_distrostring[sizeof( DISTRO_VERSION )];
    i_size = sizeof( DISTRO_VERSION ) - 1;
    i_read = fread( p_distrostring, 1, i_size, file );
    if( i_read != i_size ||
        memcmp( p_distrostring, DISTRO_VERSION, i_size ) )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache" );
        fclose( file );
        return 0;
    }
#endif

    /* Check Sub-version number */
    i_read = fread( &i_marker, 1, sizeof(i_marker), file );
    if( i_read != sizeof(i_marker) || i_marker != CACHE_SUBVERSION_NUM )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache "
                  "(corrupted header)" );
        fclose( file );
        return 0;
    }

    /* Check header marker */
    i_read = fread( &i_marker, 1, sizeof(i_marker), file );
    if( i_read != sizeof(i_marker) ||
        i_marker != ftell( file ) - (int)sizeof(i_marker) )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache "
                  "(corrupted header)" );
        fclose( file );
        return 0;
    }

    if (fread( &i_cache, 1, sizeof(i_cache), file ) != sizeof(i_cache) )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache "
                  "(file too short)" );
        fclose( file );
        return 0;
    }

    module_cache_t **pp_cache = malloc( i_cache * sizeof(*pp_cache) );
    if( pp_cache == NULL )
        i_cache = 0; /* don't load anything */

#define LOAD_IMMEDIATE(a) \
    if( fread( (void *)&a, sizeof(char), sizeof(a), file ) != sizeof(a) ) goto error
#define LOAD_STRING(a) \
{ \
    a = NULL; \
    if( ( fread( &i_size, sizeof(i_size), 1, file ) != 1 ) \
     || ( i_size > 16384 ) ) \
        goto error; \
    if( i_size ) { \
        char *psz = xmalloc( i_size ); \
        if( fread( psz, i_size, 1, file ) != 1 ) { \
            free( psz ); \
            goto error; \
        } \
        if( psz[i_size-1] ) { \
            free( psz ); \
            goto error; \
        } \
        a = psz; \
    } \
}

    for( size_t i = 0; i < i_cache; i++ )
    {
        uint16_t i_size;
        int i_submodules;

        pp_cache[i] = xmalloc( sizeof(module_cache_t) );

        /* Load common info */
        LOAD_STRING( pp_cache[i]->path );
        LOAD_IMMEDIATE( pp_cache[i]->mtime );
        LOAD_IMMEDIATE( pp_cache[i]->size );

        pp_cache[i]->p_module = vlc_module_create();

        /* Load additional infos */
        free( pp_cache[i]->p_module->psz_object_name );
        LOAD_STRING( pp_cache[i]->p_module->psz_object_name );
        LOAD_STRING( pp_cache[i]->p_module->psz_shortname );
        LOAD_STRING( pp_cache[i]->p_module->psz_longname );
        LOAD_STRING( pp_cache[i]->p_module->psz_help );

        LOAD_IMMEDIATE( pp_cache[i]->p_module->i_shortcuts );
        if( pp_cache[i]->p_module->i_shortcuts > MODULE_SHORTCUT_MAX )
            goto error;
        else if( pp_cache[i]->p_module->i_shortcuts == 0 )
            pp_cache[i]->p_module->pp_shortcuts = NULL;
        else
        {
            pp_cache[i]->p_module->pp_shortcuts =
                    xmalloc( sizeof( char ** ) * pp_cache[i]->p_module->i_shortcuts );
            for( unsigned j = 0; j < pp_cache[i]->p_module->i_shortcuts; j++ )
                LOAD_STRING( pp_cache[i]->p_module->pp_shortcuts[j] );
        }

        LOAD_STRING( pp_cache[i]->p_module->psz_capability );
        LOAD_IMMEDIATE( pp_cache[i]->p_module->i_score );
        LOAD_IMMEDIATE( pp_cache[i]->p_module->b_unloadable );

        /* Config stuff */
        if( CacheLoadConfig( pp_cache[i]->p_module, file ) != VLC_SUCCESS )
            goto error;

        LOAD_STRING( pp_cache[i]->p_module->psz_filename );
        LOAD_STRING( pp_cache[i]->p_module->domain );
        if( pp_cache[i]->p_module->domain != NULL )
            vlc_bindtextdomain( pp_cache[i]->p_module->domain );

        LOAD_IMMEDIATE( i_submodules );

        while( i_submodules-- )
        {
            module_t *p_module = vlc_submodule_create( pp_cache[i]->p_module );
            free( p_module->psz_object_name );
            free( p_module->pp_shortcuts );
            LOAD_STRING( p_module->psz_object_name );
            LOAD_STRING( p_module->psz_shortname );
            LOAD_STRING( p_module->psz_longname );
            LOAD_STRING( p_module->psz_help );

            LOAD_IMMEDIATE( p_module->i_shortcuts );
            if( p_module->i_shortcuts > MODULE_SHORTCUT_MAX )
                goto error;
            else if( p_module->i_shortcuts == 0 )
                p_module->pp_shortcuts = NULL;
            else
            {
                p_module->pp_shortcuts = xmalloc( sizeof( char ** ) * p_module->i_shortcuts );
                for( unsigned j = 0; j < p_module->i_shortcuts; j++ )
                    LOAD_STRING( p_module->pp_shortcuts[j] );
            }

            LOAD_STRING( p_module->psz_capability );
            LOAD_IMMEDIATE( p_module->i_score );
            LOAD_IMMEDIATE( p_module->b_unloadable );
            LOAD_STRING( p_module->domain );
        }
    }
    fclose( file );

    *r = pp_cache;
    return i_cache;

 error:

    msg_Warn( p_this, "plugins cache not loaded (corrupted)" );

    /* TODO: cleanup */
    fclose( file );
    return 0;
}
示例#16
0
文件: cache.c 项目: 0xheart0/vlc
/**
 * Loads a plugins cache file.
 *
 * This function will load the plugin cache if present and valid. This cache
 * will in turn be queried by AllocateAllPlugins() to see if it needs to
 * actually load the dynamically loadable module.
 * This allows us to only fully load plugins when they are actually used.
 */
size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t **r )
{
    char *psz_filename;
    FILE *file;
    int i_size, i_read;
    char p_cachestring[sizeof(CACHE_STRING)];
    int32_t i_marker;

    assert( dir != NULL );

    *r = NULL;
    if( asprintf( &psz_filename, "%s"DIR_SEP CACHE_NAME, dir ) == -1 )
        return 0;

    msg_Dbg( p_this, "loading plugins cache file %s", psz_filename );

    file = vlc_fopen( psz_filename, "rb" );
    if( !file )
    {
        msg_Warn( p_this, "cannot read %s: %s", psz_filename,
                  vlc_strerror_c(errno) );
        free( psz_filename );
        return 0;
    }
    free( psz_filename );

    /* Check the file is a plugins cache */
    i_size = sizeof(CACHE_STRING) - 1;
    i_read = fread( p_cachestring, 1, i_size, file );
    if( i_read != i_size ||
        memcmp( p_cachestring, CACHE_STRING, i_size ) )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache" );
        fclose( file );
        return 0;
    }

#ifdef DISTRO_VERSION
    /* Check for distribution specific version */
    char p_distrostring[sizeof( DISTRO_VERSION )];
    i_size = sizeof( DISTRO_VERSION ) - 1;
    i_read = fread( p_distrostring, 1, i_size, file );
    if( i_read != i_size ||
        memcmp( p_distrostring, DISTRO_VERSION, i_size ) )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache" );
        fclose( file );
        return 0;
    }
#endif

    /* Check sub-version number */
    i_read = fread( &i_marker, 1, sizeof(i_marker), file );
    if( i_read != sizeof(i_marker) || i_marker != CACHE_SUBVERSION_NUM )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache "
                  "(corrupted header)" );
        fclose( file );
        return 0;
    }

    /* Check header marker */
    i_read = fread( &i_marker, 1, sizeof(i_marker), file );
    if( i_read != sizeof(i_marker) ||
        i_marker != ftell( file ) - (int)sizeof(i_marker) )
    {
        msg_Warn( p_this, "This doesn't look like a valid plugins cache "
                  "(corrupted header)" );
        fclose( file );
        return 0;
    }

    module_cache_t *cache = NULL;
    size_t count = 0;
    char *path = NULL;

    for (;;)
    {
        module_t *module = CacheLoadModule (file);
        if (module == NULL)
        {
            if (feof (file))
                break;
            goto error;
        }

        struct stat st;

        /* Load common info */
        LOAD_STRING(path);
        if (path == NULL)
            goto error;
        LOAD_IMMEDIATE(st.st_mtime);
        LOAD_IMMEDIATE(st.st_size);

        CacheAdd (&cache, &count, path, &st, module);
        free (path);
        path = NULL;
        /* TODO: deal with errors */
    }

    fclose( file );

    *r = cache;
    return count;

error:
    free( path );
    if (ferror (file))
        msg_Err(p_this, "plugins cache read error: %s", vlc_strerror_c(errno));
    msg_Warn( p_this, "plugins cache not loaded (corrupted)" );

    /* TODO: cleanup */
    fclose( file );
    return 0;
}
示例#17
0
int main()
{
   std::string ApplicationName    = LOAD_STRING(IDS_APPLICATION_NAME);
   std::string ApplicationVersion = LOAD_STRING(IDS_APPLICATION_VERSION);
   std::string RequestMessage     = LOAD_STRING(IDS_REQUEST_MESSAGE);
   std::string ResponseMessage    = LOAD_STRING(IDS_RESPONSE_MESSAGE);
   std::string PipeName           = LOAD_STRING(IDS_PIPE_NAME);

   HANDLE hPipe;
   TCHAR  chBuf[BUFSIZE];
   BOOL   fSuccess;
   DWORD  cbRead, cbWritten, dwMode;

// Try to open a named pipe; wait for it, if necessary.

   while (1) 
   { 
      hPipe = CreateFile( 
         PipeName.c_str(), // pipe name
         GENERIC_READ |    // read and write access
         GENERIC_WRITE,
         0,                // no sharing
         NULL,             // default security attributes
         OPEN_EXISTING,    // opens existing pipe
         0,                // default attributes
         NULL);            // no template file
 
   // Break if the pipe handle is valid. 
 
      if (hPipe != INVALID_HANDLE_VALUE) 
         break; 
 
      // Exit if an error other than ERROR_PIPE_BUSY occurs.
 
      if (GetLastError() != ERROR_PIPE_BUSY)
      {
        cout << "Error. This PowerFailHandler utility cannot find a running " << ApplicationName.c_str() << " application," << endl
           << "and will be closed." << endl;
        Sleep(3000);

        return 0;
      }
 
      // All pipe instances are busy, so wait for 20 seconds. 
 
      if (!WaitNamedPipe(PipeName.c_str(), 20000))
      { 
        cout << "Error. Could not open pipe." << endl;
        Sleep(3000);

        return 0;
      }
   } 
 
// The pipe connected; change to message-read mode. 
 
   dwMode = PIPE_READMODE_MESSAGE; 
   fSuccess = SetNamedPipeHandleState( 
      hPipe,    // pipe handle 
      &dwMode,  // new pipe mode
      NULL,     // don't set maximum bytes 
      NULL);    // don't set maximum time 
   if (!fSuccess) 
   {
      cout << "Error. SetNamedPipeHandleState failed" << endl;
      Sleep(3000);

      return 0;
   }

// Send a message to the pipe server.

   fSuccess = WriteFile( 
      hPipe,                  // pipe handle 
      RequestMessage.c_str(), // message 
      RequestMessage.size(),  // message length
      &cbWritten,             // bytes written 
      NULL);                  // not overlapped 
   if (!fSuccess) 
   {
      cout << "Error. WriteFile failed" << endl;
      Sleep(3000);

      return 0;
   }
 
   do 
   { 
   // Read from the pipe. 
 
      fSuccess = ReadFile( 
         hPipe,    // pipe handle 
         chBuf,    // buffer to receive reply
         BUFSIZE*sizeof(TCHAR),  // size of buffer 
         &cbRead,  // number of bytes read 
         NULL);    // not overlapped 
 
      if (! fSuccess && GetLastError() != ERROR_MORE_DATA) 
         break; 
 
//      _tprintf( TEXT("%s\n"), chBuf ); 
   } while (!fSuccess);  // repeat loop if ERROR_MORE_DATA 

   CloseHandle(hPipe);

   if (ResponseMessage.compare(std::string(chBuf)) == 0)
   {
      cout << "Success. " << ApplicationName.c_str() << " application successfully received a PowerFail message." << endl
           << "exiting."  << endl;
      Sleep(3000);

      return 1;
   } else
   {
      cout << ApplicationName.c_str() << " application did not respond as expected to a PowerFail message." << endl
           << "exiting."  << endl;
      Sleep(3000);

      return 0;
   }
}
示例#18
0
void CCommandProcessor::OnClientCheckout(BYTE *pBuffer, size_t bufLen)
{
	MANAGER_CLIENT_DISCONNECT mcd = {0};

	GetBody(pBuffer, &mcd, sizeof(MANAGER_CLIENT_DISCONNECT));

	CString strTermID = CA2W(mcd.termID);
	CString strIP = CA2W(mcd.termIP);

	INT_PTR nIndex = m_lpLocalServer->ComputerList.Find(strTermID, strIP);
	
	if (nIndex >= 0)
	{
		CComputerInfo& computer = m_lpLocalServer->ComputerList.GetComputer(nIndex);
		computer.SetComputerStatus(CComputerInfo::ECS_LOCKED);
		
		//nCheckoutType:0换机,1临时下机,2会员下机,101临时虚拟冻结下机,102会员虚拟冻结下机
		CActiveMember ActiveMember; //用户没钱自动锁屏,就是离线了
		BOOL bGet = m_lpLocalServer->ActiveMemberList.GetActiveMember(computer.GetMemberID(), ActiveMember);

		if (0 == mcd.nCheckoutType)//用户换机了
		{
			if (bGet)
			{
				if (ActiveMember.GetAvailavleBalance() == 0) //没钱了
				{
					ActiveMember.SetTerminalID(_T(""));
					ActiveMember.SetStatus(CActiveMember::EStatus_CenterOnLine);//中心在线状态,为了加速查询
					m_lpLocalServer->ActiveMemberList.UpdateActiveMember(ActiveMember, TRUE);

					CClientShortMessage csm;

					CIBAString strBody;
					strBody.LoadString(IDS_NOMONEYLOCK);
					csm.SetMsgBody(strBody);
					csm.SetTermID(computer.GetTerminalID());
					csm.SetTermIP(computer.GetComputerIP());
					csm.SetRevTime(CIBAHelpper::GetCurrentTimeAsString(TRUE));
					csm.SetMemberId(computer.GetMemberID());

					CIBADAL::GetInstance()->AddClientShortMsg(csm);
				}
			}
		}
		else
		{
			// 2011/11/04-8210-gxx: 
			if (bGet)
			{
				if (ActiveMember.GetRoomMemberId() == 0)
				{
					m_lpLocalServer->ActiveMemberList.RemoveActiveMember(computer.GetMemberID());
				}
				else
				{
					// 包房用户不做清除
					ActiveMember.SetRoomMemberId(0);
					ActiveMember.SetTerminalID(_T("")); // 终端号置空
					ActiveMember.SetPCClassID(0);
					ActiveMember.SetRemark(LOAD_STRING(IDS_ROOM_HAS_REFUND));
					CLocalServer::GetInstance()->ActiveMemberList.UpdateActiveMember(ActiveMember, TRUE);
				}
			}
			

			computer.ClearUserInfo();

			if (2 == mcd.nCheckoutType || 102 == mcd.nCheckoutType) //会员下机
			{
				CClientShortMessage csm;
	
				CIBAString strBody;
				strBody.LoadString(IDS_PAYOUTMEMBER);
				csm.SetMsgBody(strBody);
				csm.SetTermID(computer.GetTerminalID());
				csm.SetTermIP(computer.GetComputerIP());
				csm.SetRevTime(CIBAHelpper::GetCurrentTimeAsString(TRUE));
				csm.SetMemberId(computer.GetMemberID());

				CIBADAL::GetInstance()->AddClientShortMsg(csm);

				//((CMainFrame*)AfxGetMainWnd())->m_wndOutput.UpdateMsgLog();
			}
		}
		
		m_lpLocalServer->ComputerList.UpdateComputer(nIndex, computer);
		m_lpLocalServer->GetComputerListView()->Refresh(FALSE);
		m_lpLocalServer->GetActiveMemberView()->Refresh(FALSE);
	}
}
示例#19
0
LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM)
{
	UINT uiToolBarId = (UINT)wp;

	if (IDR_FASTDLG == uiToolBarId)
	{
		m_wndFastLane.ReplaceButtons();	
	}
	else if (IDR_MAINFRAME == uiToolBarId )
	{
		CIdentityToolbarButton btnLabel(ID_LABEL,&m_wndToolBar);
		btnLabel.SetCtrlWindowText(m_strLastIdInToolbar);
		int i = m_wndToolBar.ReplaceButton(ID_LABEL,btnLabel);

#ifndef __USING_INTER_RESOURCE

		const UINT nSize = 11;
		UINT nCmds[nSize] = {
			ID_DUTY_OFF,
			IDM_MYREFRESH,            // 刷新(F1)
			IDM_NEWUSER,              // 开户(F2)
			IDM_CREDIT,               // 充值(F3)
			IDM_CREDITREVERSE,        // 充值修正(F4)
			IDM_CARDCREDIT,           // 充值卡充值(F5)
			IDM_MODIFYPWD,            // 修改密码(F7)
			IDM_BOUNDTIME,            // 包时(F10)
			IDM_SELL,                 // 商品销售(F12)
			ID_ZENGSHOUBAO,
			IDM_DIANKA                // 点卡销售(F11)
		};
		TCHAR *pAccclerators[nSize] = {
			_T(""),
			_T("(F1)"),
			_T("(F2)"),
			_T("(F3)"),
			_T("(F4)"),
			_T("(F5)"),
			_T("(F7)"),
			_T("(F10)"),
			_T("(F12)"),	
			_T(""),
			_T("(F11)")
		};
		for(UINT n = 0; n < nSize; n++)
		{
			int nIndex = m_wndToolBar.CommandToIndex(nCmds[n]);
			if (nIndex < 0)
			{
				continue;
			}
			CString strTxt = LOAD_STRING(nCmds[n]);
			if (strTxt == _T("Unknown string ID"))
			{
				continue;
			}
			strTxt.TrimLeft(_T('\n'));
			int nRes = strTxt.ReverseFind(_T('('));
			if (nRes > 0)
			{
				strTxt = strTxt.Left(nRes);
			}

			strTxt += pAccclerators[n];
			m_wndToolBar.SetButtonText(nIndex, strTxt);	
		}
		
		CString strMainCaption = LOAD_STRING(IDS_MAIN_MENU_CAPTION);
		CStringArray strArray;
		CIBAHelpper::SplitLine(strMainCaption,strArray);
		ASSERT(strArray.GetCount() == 7);
	
		for(int n = 0; n < strArray.GetCount(); n++)
		{
			m_wndMenuBar.SetButtonText(n, strArray.GetAt(n));	
		}

#endif
	
		return 0;
	}

	return 0;
}
示例#20
0
// 查询同时为列表赋值
void CCardopenConsumeView::FillList(void)
{
	//{ 2011/12/28-8236-gxx: 

	CActiveMemberList& AList = CLocalServer::GetInstance()->ActiveMemberList;
	
	CSingleLock lock(&(AList.ActiveMemberListLock), TRUE);

	CActiveMember ActiveMember;
	AList.StartEnumActiveMember();
	while(AList.GetEachActiveMember(ActiveMember))
	{
		UINT nMemberId = 0;

		if (ActiveMember.IsMember())
		{
			continue;
		}

		if (CIBAHelpper::IsValidTime(ActiveMember.GetCheckInTime()))
		{
			continue;
		}

		m_InfoList.InsertItem(0,ActiveMember.GetNetId());

		m_InfoList.SetItemText(0,1,ActiveMember.GetUserName(TRUE));

		m_InfoList.SetItemText(0,2,ActiveMember.GetPersonalID());

		CString strTmp;
		if (CIBAHelpper::IsValidTime(ActiveMember.GetActivationTime()))
		{
			strTmp = ActiveMember.GetActivationTime().Format(_T("%H:%M"));
		}
		m_InfoList.SetItemText(0,3,strTmp);

		// 备注
		CIBAString strRemark;
		if (!ActiveMember.GetIsLocalUser())
		{
			CIBAString strRegisterBT;
			strRegisterBT.LoadString(IDS_BT_NOT_PC); // 包时未上机
			strRemark = ActiveMember.GetRemark();

			if (ActiveMember.GetIsOnLine())
			{
				if (strRemark == strRegisterBT)
				{
					strRemark = _T("");
				}
			}
			else
			{
				if (ActiveMember.GetIsRegisterBT()&&(strRemark==strRegisterBT||strRemark.IsEmpty()))
				{
					strRemark = strRegisterBT;
				}
			}
		}
		else
		{
			strRemark.LoadString(IDS_LOCALUSER); // 本地用户
		}
		m_InfoList.SetItemText(0,4,strRemark);
	}

	m_strNoConsumeResult.Format(LOAD_STRING(IDS_NOCONSUME), m_InfoList.GetItemCount());

	//}

	//QueryRegister();

	//int nNoConsume = m_InfoList.GetItemCount();
 //	for(int i = 0; i < m_InfoList.GetItemCount(); i++)
 //	{
	//	CString strMemberId = m_InfoList.GetItemText(i, 4), strCardOpenTime;
	//	strCardOpenTime = m_InfoList.GetItemText(i, 5);
	//	strCardOpenTime.Trim();

	//	BOOL bIsConsume = QueryHistotyConsume(strMemberId, strCardOpenTime) || QueryActiveConsume(strMemberId);

	//	m_InfoList.SetItemText(i, 2, GetCardStateAsString(bIsConsume));
	//	nNoConsume -= (int)bIsConsume;
	//	// 删除已经消费的记录
	//	if (bIsConsume)
	//	{
	//		m_InfoList.DeleteItem(i);
	//		i--;
	//	}
	//} 
	//
	//m_strNoConsumeResult.Format(LOAD_STRING(IDS_NOCONSUME), nNoConsume);
}
示例#21
0
// Application init function (override)
bool CQ2RTApplication::AppInit(void)
{
	if(QFileSystemInit() != Q_NO_ERROR)
		QMonitor.WarningMessage("Can not initialize file system");
#ifdef OS_VXWORKS
	else
	{
		// Set starting work directory
		if(QChangeDirectory(APPLICATION_FILE_PATH) != Q_NO_ERROR)
			QMonitor.WarningMessage("Can not change directory to application directory");
	}

	AppFilePath.Value() = APPLICATION_FILE_PATH;
#endif

	// Set high priority for this process (windows only)
#ifdef OS_WINDOWS
	SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
#endif

	// Init application parameters manager
	if(! CAppParams::Init(AppFilePath.Value() + LOAD_STRING(IDS_CONFIGS_DIRNAME)))
		return false;
	// Initialize the global error handler
	CErrorHandler::Init();

	// Initialize the log file
	InitLogFile();

	// Create a mini-sequencer object
	m_MiniSequencer = new CMiniSequencer("AppMiniSequencer");

	// Initilize the modes manager
	CModesManager::Init(CAppParams::Instance(), AppFilePath.Value(), m_MiniSequencer);

	CAppParams::Instance()->EnableDisableSaveEvents(true);

	InitFrontEnd();
	CModesManager::Instance()->EnterMode(DEFAULT_MODE, DEFAULT_MODES_DIR);
	CModesManager::Instance()->EnterMode(OPERATION_MODE_NAME(CAppParams::Instance()->PipesOperationMode), GENERAL_MODES_DIR);

	// Initilize the maintenance counters system
	CMaintenanceCounters::Init(NUM_OF_MAINTENANCE_COUNTERS, AppFilePath.Value() + LOAD_STRING(IDS_CONFIGS_DIRNAME) + "Maintenance.dat");
	SetMaintenanceCountersDefaultWarnings();
	CMaintenanceCounters::GetInstance()->LoadFromFile();
	SetMachineSinceDateParam(); //OBJET_MACHINE
	ApplyParametersChange();

	// Initialize the data card
	if(CHECK_NOT_EMULATION(CAppParams::Instance()->DataCard_Emulation))
	{
		DWORD dwStatus = EdenPCISystem_Init();
		if(dwStatus != WD_STATUS_SUCCESS)
		{
			m_IsPciCardInitialized = false;
			CQLog::Write(LOG_TAG_PRINT, QFormatStr("Data PCI card problem, dwStatus: %s", Stat2Str(dwStatus)));
			QMonitor.WarningMessage(QFormatStr("Data PCI card problem: %s", Stat2Str(dwStatus)));
		}
		else
		{
			m_IsPciCardInitialized = true;
			SetFIFOUnderrunErrorCallback(FIFOUnderrunErrorCallback, NULL);
		}
	}

	// Initialize communication related components
	InitCommComponents();

	m_LayerProcess   = new CLayerProcess;
	m_HostComm = new CHostComm;

	// Create a mini-sequencer object

	// Create other system objects

	m_MachineManager = new CMachineManager;
	m_Tester         = new CTester;

	// Initialize BIT system
	m_BITManager = new CBITManager;
	AppBIT::Init();
	RefreshBIT();

#ifdef OBJET_MACHINE
	CActionsHistoryTable::GetInstance()->Init();
#endif

	// Protect "Show incoming slices" menu
	// ------------------------------------------------------------------------
	Chasp hasp(ChaspFeature::fromFeature(INT_FROM_RESOURCE(IDN_HASP_INCOMING_SLICES_PROTECTION_FEATURE)));
	try
	{
		haspStatus status = hasp.login(HASP_OBJET_VENDOR_CODE, HASP_LOCAL_SCOPE);
		bool show = false;
		if(HASP_SUCCEEDED(status))
		{
			show = true;
		}
		else
		{
			show = false;
		}
		m_MachineManager->GetMachineSequencer()->HandleIncomingSlicesProtection(show);
	}
	__finally
	{
		hasp.logout();
	}

	// ------------------------------------------------------------------------
	 // Enable m_SolubleSupportAllowed flag
	// ------------------------------------------------------------------------

	TLicensedMaterialsList MaterialsList  = CBackEndInterface::Instance()->GetLicensedMaterialsList();

	for(TLicensedMaterialsList::iterator it = MaterialsList.begin() ; it != MaterialsList.end() ; it++)
	{
		if( it->MaterialName == "SUP707" || it->MaterialName == "SUP706" )
		{
			SetSupportReplacementAllowed(true);
			break;
		}
	}
	// ------------------------------------------------------------------------

	// ------------------------------------------------------------------------

	// Enable m_QATestsAllowed flag
	// ------------------------------------------------------------------------
	Chasp hasp1(ChaspFeature::fromFeature(INT_FROM_RESOURCE(IDN_HASP_QA_TESTS_ALLOWED_FEATURE)));
	try
	{
		haspStatus status = hasp1.login(HASP_OBJET_VENDOR_CODE, HASP_LOCAL_SCOPE);
		bool enable = false;
		if(HASP_SUCCEEDED(status))
		{
			enable = true;
		}
		else
		{
			enable = false;
		}
		SetQATestsAllowed(enable);
	}
	__finally
	{
		hasp1.logout();
	}
	// ------------------------------------------------------------------------

#ifndef EMULATION_ONLY
	//HASP feature number is generated from application version, for example Connex500 ver 57.1 - HASP feature: 571
	ChaspFeature feature = ChaspFeature::fromFeature(GetHaspFeatureNum());
	CHaspInterfaceWrapper::Init(feature, LOG_TAG_HASP, m_MachineManager->GetMachineSequencer()->HandleHaspStatus);
#else
	CHaspInterfaceWrapper::Init();
#endif

	LogThreadsProperties();

	try
	{
		m_timeoutTimer = new TTimer(NULL); //bug 5950
	}
	catch(std::bad_alloc& ba)
	{
		m_timeoutTimer = NULL;
		CQLog::Write(LOG_TAG_GENERAL, "m_timeoutTimer - Memory allocation failed: %s", ba.what());
	}

	QMonitor.SetServiceCallsCheckingMsgSafety(
	    CFrontEndInterface::IsWizardRunning,
	    CFrontEndInterface::CancelWizard);
	return true;
}
示例#22
0
void CNDCheckInDlg::OnBnClickedOk()
{
	UpdateData();

	CBCGPGridRow* pRow = m_wndGridTree.GetCurSel();

	if (pRow != NULL) 
	{
		INT_PTR nIdx = pRow->GetData();

		if (CLocalServer::GetInstance()->ComputerList.IsInvaildIndex(nIdx))
		{
			return;
		}

		CComputerInfo & computer = CLocalServer::GetInstance()->ComputerList.GetComputer(nIdx);

		if (CheckTakeUp(computer.GetTerminalID())) //占用了
		{
			MsgBox(IDS_CHANGECOMPUTERERROR);
			return;
		}
		
		//{ 2011/07/27-8201-gxx: 
		CActiveMember ActiveMember;
		if (!CLocalServer::GetInstance()->ActiveMemberList.GetActiveMemberNetID(m_strNetId, ActiveMember))
		{
			CIBALog::GetInstance()->WriteFormat(_T("上机时,从用户视图获取账号:%s对应的用户失败"), m_strNetId);
			CBCGPDialog::OnOK();
			return;
		}

		if (!GetCheckIn()) //换机登出
		{
			
		}

		// 2011/11/03-8210-gxx: 包房主账号上机
		if (ActiveMember.GetMemberID() == ActiveMember.GetRoomMemberId())
		{
			if (ActiveMember.GetPCClassID() != computer.GetPCClassID())
			{
				theApp.IBAMsgBox(LOAD_STRING(IDS_ROOM_CHECKIN_ERROR1));
				return ;
			}
		}
		
		
		//添加到数据库
		CLastUserInfo LastUserInfo;
		LastUserInfo.SetNetId(m_strNetId);
		LastUserInfo.SetMemberId(m_nMemberId);
		LastUserInfo.SetTermId(computer.GetTerminalID());
		LastUserInfo.SetLoginStyle(1/*GetCheckIn() ? 1 : 0*/); //自动登录要求传强制登录参数
		LastUserInfo.SetUpdateTime(CIBAHelpper::GetCurrentTimeAsString(TRUE));

		CString strTmp;
		if ( (int(m_nMemberId)) < 0 ) 
		{
			// 本地用户不再次加密
			LastUserInfo.SetPassWord(m_strPwd);
			if (!ActiveMember.GetTerminalID().IsEmpty())
			{
				// 本地用户换机
				CheckoutOldComputer(); // 换机登出
			}
			
			CIBADAL::GetInstance()->DeleteLastUserInfo(LastUserInfo.GetTermId());
			CIBADAL::GetInstance()->AddLastUserInfo(LastUserInfo);
		}
		else
		{
			// 中心用户
			strTmp = CIBAHelpper::EncodePassword(m_strPwd);
			LastUserInfo.SetPassWord(strTmp);

			if (!GetCheckIn() && !ActiveMember.GetTerminalID().IsEmpty())
			{
				// 中心用户换机

				CLastUserInfo tmpLastInfo;
				if (CIBADAL::GetInstance()->GetLastUserInfo(tmpLastInfo, m_nMemberId))
				{
					LastUserInfo.SetPassWord( tmpLastInfo.GetPassWord() );
				}
				
				CheckoutOldComputer(); // 换机登出

				CIBADAL::GetInstance()->DeleteLastUserInfo(LastUserInfo.GetTermId());
				CIBADAL::GetInstance()->AddLastUserInfo(LastUserInfo);

			}
			else
			{
				// 中心用户上机
				
				CIBADAL::GetInstance()->DeleteLastUserInfo(LastUserInfo.GetTermId());
				CIBADAL::GetInstance()->AddLastUserInfo(LastUserInfo);
			}
		}

		ActiveMember.SetTerminalID(computer.GetTerminalID());
		ActiveMember.SetPCClassID(computer.GetPCClassID());

		//{ 2011/10/26-8230-gxx: 
		ActiveMember.SetRoomMemberId(0);
		UINT nRoomMemberID=0;
		if ( CLocalServer::GetInstance()->ActiveMemberList.IsRoomArea(computer.GetPCClassID(), nRoomMemberID) )
		{
			ActiveMember.SetRoomMemberId(nRoomMemberID);
		}
		//}
		
		
		

		CLocalServer::GetInstance()->ActiveMemberList.UpdateActiveMember(ActiveMember, TRUE);
		CLocalServer::GetInstance()->ActiveMemberList.RefreshView();
		

		//请求登录
		
		if (computer.GetComputerStatus() == CComputerInfo::ECS_LOCKED)
		{
			CLocalServer::GetInstance()->LocalAutoCheckIn(nIdx);
		}
		else
		{
			if (m_bPowerOn) //自动开机
			{
				CLocalServer::GetInstance()->LocalStartupComputer(nIdx);
			}
		}

		MsgBoxFormat(MB_OK, IDS_CHANGECOMPUTERSUCCESS, LastUserInfo.GetTermId());

		CBCGPDialog::OnOK();
	}
}
示例#23
0
int main(int argc, char **argv) {
   // We don't check bounds here: we'd end up essentially duplicating the logic
   // from load_string, and there's little point in that.
   tap_n(2*4 + 2*2 + 2);

   if (argc > 1) {
      long s = atol(argv[1]);
      init_by_array((uint32_t*)&s, sizeof s / sizeof(uint32_t));
   } else {
      time_t s = time(NULL);
      init_by_array((uint32_t*)&s, sizeof s / sizeof(uint32_t));
   }

   void *data = malloc(DATA_LEN);
   random_fill(data, DATA_LEN);

   const size_t codepoints = DATA_LEN * CHAR_BIT / 21;

   mushcoords beg = MUSHCOORDS(MUSHCELL_MAX-WRAP_AFTER,
                               MUSHCELL_MAX-WRAP_AFTER,
                               MUSHCELL_MAX-WRAP_AFTER),
              end;

   void *space_buf = malloc(mushspace_sizeof);
   mushspace *space;

   bool ok;

   codepoint_reader cp_reader;

   mushcoords pos, pos_next;
   bool cr;

#define POS_INIT \
   pos_next = beg; \
   cr = false;

#define CP_POS(cp) \
   pos = pos_next; \
   switch (cp) { \
   default: \
      if (MUSHSPACE_DIM > 1 && cr) { \
         cr = false; \
         pos = MUSHCOORDS(beg.x, pos.y + 1, pos.z); \
      } \
      pos_next = MUSHCOORDS(pos.x + 1, pos.y, pos.z); \
      break; \
   case '\r': \
      if (MUSHSPACE_DIM > 1) { \
         if (cr) \
            pos_next = pos = MUSHCOORDS(beg.x, pos.y + 1, pos.z); \
         cr = true; \
      } \
      continue; \
   case '\n': \
      if (MUSHSPACE_DIM > 1) { \
         cr = false; \
         pos_next = pos = MUSHCOORDS(beg.x, pos.y + 1, pos.z); \
      } \
      continue; \
   case '\f': \
      if (MUSHSPACE_DIM > 2) { \
         cr = false; \
         pos_next = pos = MUSHCOORDS(beg.x, beg.y, pos.z + 1); \
      } else if (cr) { \
         cr = false; \
         pos_next = pos = MUSHCOORDS(beg.x, pos.y + 1, pos.z); \
      } \
      continue; \
   }

#define LOAD_STRING(suf, T, ENCODER, BLOWUP, FOREACH_CP) \
   space = mushspace_init(space_buf, NULL); \
   if (!space) { \
      tap_not_ok("init returned null"); \
      tap_skip_remaining("init failed"); \
      return 1; \
   } \
   tap_ok("init succeeded"); \
   \
   T *encoded_data##suf = (T*)data; \
   size_t encoded_len##suf = DATA_LEN / sizeof *encoded_data##suf; \
   if (BLOWUP) { \
      encoded_data##suf = \
         malloc((codepoints * BLOWUP) * sizeof *encoded_data##suf); \
      encoded_len##suf = ENCODER(data, encoded_data##suf, codepoints); \
   } \
   \
   mushspace_load_string##suf( \
      space, encoded_data##suf, encoded_len##suf, &end, beg, false); \
   \
   if (BLOWUP) \
      free(encoded_data##suf); \
   \
   ok = true; \
   POS_INIT; \
   FOREACH_CP(suf) { \
      CP_POS(cp##suf); \
      mushcell gc = mushspace_get(space, pos); \
      if (gc == cp##suf) \
         continue; \
      ok = false; \
      tap_not_ok("get doesn't match data given to load_string" #suf); \
      printf("  ---\n" \
             "  expected: %" MUSHCELL_PRIx "\n" \
             "  got: %" MUSHCELL_PRIx "\n" \
             "  failed index: %zu\n", \
             cp##suf, gc, ii##suf); \
      printf("  failed pos relative to min: ("); \
      for (uint8_t i = 0; i < MUSHSPACE_DIM; ++i) \
         printf(" %" MUSHCELL_PRId, mushcell_sub(pos.v[i], MUSHCELL_MIN)); \
      printf(" )\n" \
             "  ...\n"); \
      break; \
   } \
   if (ok) \
      tap_ok("get matches data given to load_string" #suf); \
   \
   mushspace_free(space);

#define DIRECT_FOREACH_CP(s) \
   mushcell cp##s; \
   size_t ii##s = 0; \
   for (; ii##s < encoded_len##s && (cp##s = encoded_data##s[ii##s], true); \
        ++ii##s)

#define READER_FOREACH_CP(s) \
   cp_reader = make_codepoint_reader(data, codepoints); \
   size_t ii##s = 0; \
   for (mushcell cp##s; (cp##s = next_codepoint(&cp_reader)) != UINT32_MAX; \
        ++ii##s)

   LOAD_STRING(, unsigned char,  dummy, 0,        DIRECT_FOREACH_CP);
   LOAD_STRING(_cell,  mushcell, dummy, 0,        DIRECT_FOREACH_CP);
   LOAD_STRING(_utf8,  uint8_t,  encode_utf8,  4, READER_FOREACH_CP);
   LOAD_STRING(_utf16, uint16_t, encode_utf16, 2, READER_FOREACH_CP);

   const mushcell *data_cell       = (const mushcell*)data;
   const size_t    data_cell_count = DATA_LEN / sizeof *data_cell;

   mushcoords *saved_pos = malloc(data_cell_count * sizeof *saved_pos);

#define PUT(FOREACH_CELL, S, GET_POS, SAVE_POS) \
   space = mushspace_init(space_buf, NULL); \
   if (!space) { \
      tap_not_ok("init returned null"); \
      tap_skip_remaining("init failed"); \
      free(saved_pos); \
      return 1; \
   } \
   tap_ok("init succeeded"); \
   POS_INIT; \
   FOREACH_CELL { \
      GET_POS(data_cell[i]); \
      if (SAVE_POS) \
         saved_pos[i] = pos; \
      mushspace_put(space, pos, data_cell[i]); \
   } \
   \
   ok = true; \
   POS_INIT; \
   for (size_t i = 0; i < data_cell_count; ++i) { \
      mushcell dc = data_cell[i]; \
      GET_POS(dc); \
      mushcell gc = mushspace_get(space, pos); \
      if (gc == dc) \
         continue; \
      ok = false; \
      tap_not_ok("get doesn't match what was put" S); \
      printf("  ---\n" \
             "  failed index: %zu\n" \
             "  expected: %" MUSHCELL_PRIx "\n" \
             "  got: %" MUSHCELL_PRIx "\n", \
             i, dc, gc); \
      printf("  failed pos relative to min: ("); \
      for (uint8_t j = 0; j < MUSHSPACE_DIM; ++j) \
         printf(" %" MUSHCELL_PRId, mushcell_sub(pos.v[j], MUSHCELL_MIN)); \
      printf(" )\n" \
             "  ...\n"); \
      break; \
   } \
   if (ok) \
      tap_ok("get matches what was put" S);

#define FORWARD for (size_t i = 0; i < data_cell_count; ++i)
#define REVERSE for (size_t i = data_cell_count; i--;)

#define SAVED_POS(_) pos = saved_pos[i];

   PUT(FORWARD, " (forward order)", CP_POS, true);
   mushspace_free(space);
   PUT(REVERSE, " (reverse order)", SAVED_POS, false);
   free(saved_pos);

   if (!ok) {
      tap_skip_remaining("won't copy bad space");
      return 1;
   }

   void *space_buf2 = malloc(mushspace_sizeof);

   mushspace *space2 = mushspace_copy(space_buf2, space, NULL);
   mushspace_free(space);
   free(space_buf);

   space = space2;

   if (!space) {
      tap_not_ok("copy returned null");
      tap_skip_remaining("copy failed");
      return 1;
   }
   tap_ok("copy succeeded");

   ok = true;
   POS_INIT;
   for (size_t i = 0; i < DATA_LEN / sizeof *data_cell; ++i) {
      mushcell dc = data_cell[i];
      CP_POS(dc);
      mushcell gc = mushspace_get(space, pos);
      if (gc == dc)
         continue;
      ok = false;
      tap_not_ok("get in copy doesn't match data");
      printf("  ---\n"
             "  failed index: %zu\n"
             "  expected: %" MUSHCELL_PRIx "\n"
             "  got: %" MUSHCELL_PRIx "\n",
             i, dc, gc);
      printf("  failed pos relative to min: (");
      for (uint8_t j = 0; j < MUSHSPACE_DIM; ++j)
         printf(" %" MUSHCELL_PRId, mushcell_sub(pos.v[j], MUSHCELL_MIN)); \
      printf(" )\n"
             "  ...\n");
      break;
   }
   if (ok)
      tap_ok("get in copy matched data");

   free(data);
   mushspace_free(space);
   free(space_buf2);
}
示例#24
0
void CIBAOutputBar::SetCreditInfo(COperationInfo &OperationInfo)
{
	m_wndListInfo.SetItemText(0, 2, OperationInfo.GetUserName());

	m_wndListInfo.SetItemText(0, 3, FormatNetId(OperationInfo.GetNetId()));

	CString strTmp;
	strTmp.Format(_T("%.2f"), OperationInfo.GetOperationAmount() / 100.0);
	m_wndListInfo.SetItemText(0, 4, strTmp);
	
	CString strDescription;

	if (OperationInfo.GetPresentAmount() > 0)
	{
		strDescription.AppendFormat(LOAD_STRING(IDS_PRESENT_FORMAT), OperationInfo.GetPresentAmount() / 100.0); // 赠送:%.2f
	}
	
	if (OperationInfo.GetDeposit() > 0)
	{
		if (!strDescription.IsEmpty())
		{
			strDescription.Append(_T(","));
		}

		strDescription.AppendFormat(LOAD_STRING(IDS_DEPOSIT_FORMAT), OperationInfo.GetDeposit() / 100.0); // 押金:%.2f
	}

	if (!OperationInfo.GetPassWord().IsEmpty())
	{
		if (CNetBarConfig::GetInstance()->GetRealNamePassword() < 2)
		{
			if (!strDescription.IsEmpty())
			{
				strDescription.Append(_T(","));
			}

			strDescription.AppendFormat(LOAD_STRING(IDS_PASSWORD_FORMAT), OperationInfo.GetPassWord()); // 密码:%s
		}
	}

	if (OperationInfo.GetIsBundTime())
	{
		if (!strDescription.IsEmpty())
		{
			strDescription.Append(_T(","));
		}

		strDescription.AppendFormat(_T(""), OperationInfo.GetBundTimeAmount() / 100.0); // 包时金额:%.2f
	}

	if (!OperationInfo.GetDescription().IsEmpty())
	{
		if (!strDescription.IsEmpty())
		{
			strDescription.Append(_T(","));
		}

		strDescription.Append(OperationInfo.GetDescription());
	}
	
	m_wndListInfo.SetItemText(0, 5, strDescription);
}