示例#1
0
bool emAlarmClockPanel::Cycle()
{
	bool busy;
	int value;

	busy=emFilePanel::Cycle();

	if (
		IsSignaled(GetVirFileStateSignal()) ||
		IsSignaled(FileModel->GetChangeSignal()) ||
		IsSignaled(AlarmModel->GetChangeSignal())
	) {
		UpdateFieldsAndButtons();
	}

	if (IsSignaled(TimeField->GetValueSignal())) {
		if (IsVFSGood()) {
			value=(int)TimeField->GetValue();
			FileModel->AlarmHour=value/3600;
			FileModel->AlarmMinute=value/60%60;
			FileModel->AlarmSecond=value%60;
			FileModel->Save(true);
			if (
				AlarmModel->IsAlarmEnabled() &&
				AlarmModel->GetAlarmSecOfDay()!=value
			) {
				AlarmModel->EnableAlarm(GetIdentity(),value);
			}
		}
	}

	if (IsSignaled(OnButton->GetClickSignal())) {
		if (IsVFSGood()) {
			value=(int)TimeField->GetValue();
			AlarmModel->EnableAlarm(GetIdentity(),value);
		}
	}

	if (IsSignaled(OffButton->GetClickSignal())) {
		AlarmModel->DisableAlarm();
	}

	if (IsSignaled(TestButton->GetClickSignal())) {
		AlarmModel->Beep();
	}

	if (IsSignaled(ConfirmButton->GetClickSignal())) {
		AlarmModel->ConfirmAlarm();
	}

	return busy;
}
/*
Initializes TWAIN interface . Is already called from the constructor. 
It should be called again if ReleaseTwain is called.

  hWnd is the window which has to subclassed in order to recieve
  Twain messaged. Normally - this would be your main application window.

*/
BOOL CTwain::InitTwain(HWND hWnd)
{
char libName[512];
	if(IsValidDriver()) 
	{
		return TRUE;
	}
	memset(&m_AppId,0,sizeof(m_AppId));
	if(!IsWindow(hWnd))
	{
		return FALSE;
	}
	m_hMessageWnd = hWnd;
	strcpy(libName,"TWAIN_32.DLL");
	
	m_hTwainDLL  = LoadLibrary(libName);
	if(m_hTwainDLL != NULL)
	{
		if(!(m_pDSMProc = (DSMENTRYPROC)GetProcAddress(m_hTwainDLL,MAKEINTRESOURCE(1))))
		{
			FreeLibrary(m_hTwainDLL);
			m_hTwainDLL = NULL;
		}
	}
	if(IsValidDriver())
	{
		GetIdentity();
		m_bDSMOpen= CallTwainProc(&m_AppId,NULL,DG_CONTROL,DAT_PARENT,MSG_OPENDSM,(TW_MEMREF)&m_hMessageWnd);
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
示例#3
0
STDMETHODIMP
CEapCfg::RouterInvokeCredentialsUI(
    DWORD       dwEapTypeId,
    ULONG_PTR   uConnectionParam,
    HWND        hwndParent,
    DWORD       dwFlags,
    BYTE*       pConnectionDataIn,
    DWORD       dwSizeOfConnectionDataIn,
    BYTE*       pUserDataIn,
    DWORD       dwSizeOfUserDataIn,
    BYTE**      ppUserDataOut,
    DWORD*      pdwSizeOfUserDataOut
)
{
    BYTE*       pUserDataOut            = NULL;
    DWORD       dwSizeOfUserDataOut;
    WCHAR*      pwszIdentityOut         = NULL;
    DWORD       dwErr                   = NO_ERROR;

    *ppUserDataOut = NULL;
    *pdwSizeOfUserDataOut = 0;

    dwErr = GetIdentity(
                    hwndParent,
                    NULL /* pUserDataIn */,
                    0 /* dwSizeOfUserDataIn */,
                    &pUserDataOut,
                    &dwSizeOfUserDataOut,
                    &pwszIdentityOut);

    if (   (NO_ERROR == dwErr)
        && (0 != dwSizeOfUserDataOut))
    {
        //
        // If we got valid UserDataOut, allocate memory for it...
        //

        *ppUserDataOut = (BYTE*)CoTaskMemAlloc(dwSizeOfUserDataOut);

        if (NULL == *ppUserDataOut)
        {
            dwErr = ERROR_NOT_ENOUGH_MEMORY;
            goto LDone;
        }

        //
        // ... and return it in the OUT parameter
        //

        CopyMemory(*ppUserDataOut, pUserDataOut, dwSizeOfUserDataOut);
        *pdwSizeOfUserDataOut = dwSizeOfUserDataOut;
    }

LDone:

    LocalFree(pUserDataOut);
    LocalFree((BYTE*)pwszIdentityOut);

    return(HRESULT_FROM_WIN32(dwErr));
}
示例#4
0
Matrix4 Matrix4::GetTranslate(float dx, float dy, float dz) {
	Matrix4 m = GetIdentity();
	m(0, 3) = dx;
	m(1, 3) = dy;
	m(2, 3) = dz;
	return m;
}
示例#5
0
Matrix4 Matrix4::GetScale(float sx, float sy, float sz) {
	Matrix4 m = GetIdentity();
	m(0, 0) = sx;
	m(1, 1) = sy;
	m(2, 2) = sz;
	return m;
}
示例#6
0
Element ByteGroup::Exponentiate(const Element &a, const Integer &exp) const
{
    if((exp % Integer(2)) == 0) {
        return GetIdentity();
    } else {
        return a;
    }
}
示例#7
0
文件: Math.cpp 项目: janivanecky/Bark
const Matrix4x4 Math::GetScale(const float sx, const float sy, const float sz)
{
    Matrix4x4 result = GetIdentity();
    result[0] = sx;
    result[5] = sy;
    result[10] = sz;
    return result;
}
示例#8
0
Matrix4 Matrix4::GetRotateAroundZ(float degrees) {
	float radians = degrees * td::PI / 180.0f;
	Matrix4 m = GetIdentity();
	m(0, 0) = cos(radians);
	m(0, 1) = -sin(radians);
	m(1, 0) = sin(radians);
	m(1, 1) = cos(radians);
	return m;
}
示例#9
0
文件: LeaseSet.cpp 项目: h0bbyte/i2pd
	LeaseSet::LeaseSet (std::shared_ptr<const i2p::tunnel::TunnelPool> pool):
		m_IsValid (true)
	{	
		if (!pool) return;
		// header
		auto localDestination = pool->GetLocalDestination ();
		if (!localDestination)
		{
			m_Buffer = nullptr;
			m_BufferLen = 0;
			m_IsValid = false;
			LogPrint (eLogError, "LeaseSet: Destination for local LeaseSet doesn't exist");
			return;
		}	
		m_Buffer = new uint8_t[MAX_LS_BUFFER_SIZE];
		m_BufferLen = localDestination->GetIdentity ()->ToBuffer (m_Buffer, MAX_LS_BUFFER_SIZE);
		memcpy (m_Buffer + m_BufferLen, localDestination->GetEncryptionPublicKey (), 256);
		m_BufferLen += 256;
		auto signingKeyLen = localDestination->GetIdentity ()->GetSigningPublicKeyLen ();
		memset (m_Buffer + m_BufferLen, 0, signingKeyLen);
		m_BufferLen += signingKeyLen;
		auto tunnels = pool->GetInboundTunnels (5); // 5 tunnels maximum
		m_Buffer[m_BufferLen] = tunnels.size (); // num leases
		m_BufferLen++;
		// leases
		for (auto it: tunnels)
		{	
			memcpy (m_Buffer + m_BufferLen, it->GetNextIdentHash (), 32);
			m_BufferLen += 32; // gateway id
			htobe32buf (m_Buffer + m_BufferLen, it->GetNextTunnelID ());
			m_BufferLen += 4; // tunnel id
			uint64_t ts = it->GetCreationTime () + i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT - i2p::tunnel::TUNNEL_EXPIRATION_THRESHOLD; // 1 minute before expiration
			ts *= 1000; // in milliseconds
			ts += rand () % 6; // + random milliseconds 0-5
			htobe64buf (m_Buffer + m_BufferLen, ts);
			m_BufferLen += 8; // end date
		}
		// signature
		localDestination->Sign (m_Buffer, m_BufferLen, m_Buffer + m_BufferLen);
		m_BufferLen += localDestination->GetIdentity ()->GetSignatureLen (); 
		LogPrint (eLogDebug, "LeaseSet: Local LeaseSet of ", tunnels.size (), " leases created");

		ReadFromBuffer ();
	}
示例#10
0
Matrix4 Matrix4::GetOrtho(float l, float r, float b, float t, float n, float f) {
	Matrix4 m = GetIdentity();
	m(0, 0) = 2.0f / (r - l);
	m(1, 1) = 2.0f / (t - b);
	m(2, 2) = 2.0f / (n - f);
	m(0, 3) = -(r + l) / (r - l);
	m(1, 3) = -(t + b) / (t - b);
	m(2, 3) = -(n + f) / (n - f);
	return m;
}
示例#11
0
 void RouterContext::SaveKeys ()
 {   
     std::ofstream fk (i2p::util::filesystem::GetFullPath (ROUTER_KEYS).c_str (), std::ofstream::binary | std::ofstream::out);
     i2p::data::Keys keys;
     memcpy (keys.privateKey, m_Keys.GetPrivateKey (), sizeof (keys.privateKey));
     memcpy (keys.signingPrivateKey, m_Keys.GetSigningPrivateKey (), sizeof (keys.signingPrivateKey));
     auto& ident = GetIdentity ().GetStandardIdentity ();    
     memcpy (keys.publicKey, ident.publicKey, sizeof (keys.publicKey));
     memcpy (keys.signingKey, ident.signingKey, sizeof (keys.signingKey));
     fk.write ((char *)&keys, sizeof (keys));    
 }
示例#12
0
emTestPanel::~emTestPanel()
{
	if (BgColor!=DefaultBgColor) {
		emVarModel<emColor>::Set(
			GetView(),
			"emTestPanel - BgColor of " + GetIdentity(),
			BgColor,
			10
		);
	}
}
示例#13
0
emTestPanel::emTestPanel(ParentArg parent, const emString & name)
	: emPanel(parent,name)
{
	DefaultBgColor=0x001C38FF;

	BgColor=emVarModel<emColor>::GetAndRemove(
		GetView(),
		"emTestPanel - BgColor of " + GetIdentity(),
		DefaultBgColor
	);

	EnableAutoExpansion();
	SetAutoExpansionThreshold(900.0);
}
            bool SearchResultMenuViewModel::CanShowOnScreen() const
            {
                if(!m_hasSearchQuery || !m_enabled)
                {
                    return false;
                }

                if(m_reactionControllerModel.IsAnyOpenableOpen())
                {
                    return m_reactionControllerModel.IsOpenableOpen(GetIdentity());
                }

                return true;
            }
示例#15
0
Matrix4 Matrix4::GetPerspective(float fovy, float aspect_ration, float n, float f) {
	float t = n * tan(fovy / 2.0f * td::PI / 180.0f);
	float r = aspect_ration * t;

	Matrix4 m = GetIdentity();
	m(0, 0) = n / r;
	m(1, 1) = n / t;
	m(2, 2) = -(f + n) / (f - n);
	m(2, 3) = -2.0f * f * n / (f - n);
	m(3, 2) = -1.0f;
	m(3, 3) = 0.0f;

	return m;
}
示例#16
0
void emTestPanel::UpdateControlPanel()
{
	if (ControlPanel) {
		ControlPanel->SetCaption(
			emString::Format(
				"This is just a test\n"
				"\n"
				"Panel Identity: %s\n"
				"BgColor: 0x%08X",
				GetIdentity().Get(),
				(int)BgColor
			)
		);
	}
}
示例#17
0
void RouterContext::NewRouterInfo() {
  i2p::data::RouterInfo routerInfo;
  routerInfo.SetRouterIdentity(
      GetIdentity());
  routerInfo.AddSSUAddress(m_Host, m_Port, routerInfo.GetIdentHash());
  routerInfo.AddNTCPAddress(m_Host, m_Port);
  routerInfo.SetCaps(
      i2p::data::RouterInfo::eReachable |
      i2p::data::RouterInfo::eSSUTesting |
      i2p::data::RouterInfo::eSSUIntroducer);  // LR, BC
  routerInfo.SetProperty("netId", NETWORK_ID);
  routerInfo.SetProperty("router.version", I2P_VERSION);
  routerInfo.CreateBuffer(m_Keys);
  m_RouterInfo.Update(
      routerInfo.GetBuffer(),
      routerInfo.GetBufferLen());
}
示例#18
0
 void RouterContext::NewRouterInfo ()
 {
     i2p::data::RouterInfo routerInfo;
     routerInfo.SetRouterIdentity (GetIdentity ());
     int port = i2p::util::config::GetArg("-port", 0);
     if (!port)
         port = m_Rnd.GenerateWord32 (9111, 30777); // I2P network ports range
     routerInfo.AddSSUAddress (i2p::util::config::GetCharArg("-host", "127.0.0.1"), port, routerInfo.GetIdentHash ());
     routerInfo.AddNTCPAddress (i2p::util::config::GetCharArg("-host", "127.0.0.1"), port);
     routerInfo.SetCaps (i2p::data::RouterInfo::eReachable | 
         i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer); // LR, BC
     routerInfo.SetProperty ("coreVersion", I2P_VERSION);
     routerInfo.SetProperty ("netId", "2");
     routerInfo.SetProperty ("router.version", I2P_VERSION);
     routerInfo.SetProperty ("stat_uptime", "90m");
     routerInfo.CreateBuffer (m_Keys);
     m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ());
 }
示例#19
0
Matrix4 Matrix4::GetRotate(float degrees, const Vector4& axis /* normalized */) {
	float radians = (float) (degrees * td::PI / 180.0f);
	float sine = (float) sin(radians);
	float cosine = (float) cos(radians);
	float cos_compliment = 1.0f - cosine;

	Matrix4 m = GetIdentity();
	
	m(0, 0) = cos_compliment * axis[0] * axis[0] + cosine;
	m(0, 1) = cos_compliment * axis[0] * axis[1] - sine * axis[2];
	m(0, 2) = cos_compliment * axis[0] * axis[2] + sine * axis[1];
	
	m(1, 0) = cos_compliment * axis[1] * axis[0] + sine * axis[2];
	m(1, 1) = cos_compliment * axis[1] * axis[1] + cosine;
	m(1, 2) = cos_compliment * axis[1] * axis[2] - sine * axis[0];
	
	m(2, 0) = cos_compliment * axis[2] * axis[0] - sine * axis[1];
	m(2, 1) = cos_compliment * axis[2] * axis[1] + sine * axis[0];
	m(2, 2) = cos_compliment * axis[2] * axis[2] + cosine;
	
	return m;
}
示例#20
0
//-----------------------------------------------------------------------------
// Function:    RegisterPeerNameCommand
// Purpose:     Prompts user for registration information, fills out a
//              PEER_PNRP_REGISTRATION_INFO struct, creates a peer name,
//              and calls PeerPnrpRegister to register the peer name
// Parameters:  None
//
// NOTE: The signature of this function must adhere to the MENU_COMMAND typedef
HRESULT RegisterPeerNameCommand()
{
    WCHAR                       wzInputBuffer[256] = {0};
    WCHAR                       wzIdentity[MAX_PEERNAME_LENGTH] = {0};
    WCHAR                       wzClassifier[MAX_CLASSIFIER_LENGTH] = {0};
    HRESULT                     hr = S_OK;
    PWSTR                       pwzPeerName = NULL;
    ULONG                       cAddresses = 0;
    //ppRegAddrs is a pointer to an array of pointers to SOCKADDR structures
    SOCKADDR**                  ppRegAddrs = NULL;

    ZeroMemory(&g_RegInfo, sizeof(PEER_PNRP_REGISTRATION_INFO));

    //Collect Registration Information
    //---------------------------------

    // Addresses
    hr = GetAddress(TRUE, &cAddresses, &ppRegAddrs);
    if (SUCCEEDED(hr))
    {
        // Cloud name
        hr = GetCloudName(cAddresses != 1, celems(g_wzCloudName), g_wzCloudName);
    }

    if (SUCCEEDED(hr))
    {
        // Comment
        hr = GetComment(celems(g_wzComment), g_wzComment);
    }

    if (SUCCEEDED(hr))
    {
        // Payload
        hr = GetPayload(sizeof(g_PayloadData), (PBYTE)g_PayloadData);

        if (cAddresses == 0)
        {
            // If no addresses were specified, the payload must be non-null.
            while (PayloadSize(g_PayloadData) == 0 && SUCCEEDED(hr))
            {
                wprintf(L"Payload must be non-empty if no addresses are specified.\n");
                hr = GetPayload(sizeof(g_PayloadData), (PBYTE)g_PayloadData);
            }
        }
    }

    // Create Peer Name
    //------------------

    // If secure, get identity
    if (SUCCEEDED(hr))
    {
        wprintf(L"Secured peer name [no]: ");
        FLUSH_AND_GET_RESPONSE(hr, wzInputBuffer);

        if (SUCCEEDED(hr) && _wcsicmp(wzInputBuffer, L"yes") == 0)
        {
            hr = GetIdentity(celems(wzIdentity), wzIdentity);
        }
    }
    // Classifier
    if (SUCCEEDED(hr))
    {
        do
        {
            wprintf(L"Classifier: ");
            FLUSH_AND_GET_RESPONSE(hr, wzClassifier);

            // Classifier must be non-null.
            if (SUCCEEDED(hr) && wzClassifier[0] == L'\0')
            {
                wprintf(L"Classifier must be non-empty.\n");
            }
        } while (SUCCEEDED(hr) && wzClassifier[0] == L'\0');
    }

    // Create peer name
    if (SUCCEEDED(hr))
    {
        if (wcslen(wzIdentity) != 0)
        {
            // Create secured peer name
            hr = PeerCreatePeerName(wzIdentity, wzClassifier, &pwzPeerName);
        }
        else
        {
            // Create unsecured peer name
            hr = PeerCreatePeerName(NULL, wzClassifier, &pwzPeerName);
        }
    }

    // Fill out g_RegInfo struct
    // -------------------------
    if (wcslen(g_wzCloudName) == 0)
    {
        g_RegInfo.pwzCloudName = NULL;
    }
    else
    {
        g_RegInfo.pwzCloudName = g_wzCloudName;
    }

    //Copy in the address count and pointer to the array of pointers
    g_RegInfo.cAddresses = cAddresses;
    g_RegInfo.ppAddresses = ppRegAddrs;

    g_RegInfo.pwzComment = g_wzComment;

    if (PayloadSize(g_PayloadData) == 0)
    {
        g_RegInfo.payload.cbData = 0;
        g_RegInfo.payload.pbData = NULL;
    }
    else
    {
        g_RegInfo.payload.cbData = PayloadSize(g_PayloadData);
        g_RegInfo.payload.pbData = (PBYTE) g_PayloadData;
    }

    // Perform registration
    if (SUCCEEDED(hr))
    {
        hr = PeerPnrpRegister(pwzPeerName, &g_RegInfo, &g_hRegistration);
    }

    // Display result
    if (SUCCEEDED(hr))
    {
        wprintf(L"\nSuccessfully registered name: %s\n", pwzPeerName);
    }
    else
    {
        wprintf(L"\nError while registering name.  HRESULT=0x%x\n", hr);
        PrintError(hr);
    }

    if (pwzPeerName != NULL)
    {
        PeerFreeData(pwzPeerName);
    }

    if (ppRegAddrs != NULL)
    {
        free(ppRegAddrs);
    }
    return hr;
}
示例#21
0
文件: Math.cpp 项目: janivanecky/Bark
const Matrix4x4 Math::GetReflectionY()
{
    Matrix4x4 result = GetIdentity();
    result.v2 = -result.v2;
    return result;
}
示例#22
0
 bool CppECGroup::IsIdentity(const Element &a) const 
 {
   return (a == GetIdentity());
 }
示例#23
0
 bool IntegerGroup::IsGenerator(const Element &a) const 
 {
   return IsElement(a) 
     && ((Exponentiate(a, GetOrder()) == GetIdentity()))
     && (!(Exponentiate(a, Integer(2)) == GetIdentity()));
 }