Пример #1
0
//////////////////
// Get group margins
//
BOOL WINRECT::GetMargins(int& w, int& h)
{
	if (IsGroup()) {
		w=(short)LOWORD(param);
		h=(short)HIWORD(param);
		return TRUE;
	}
	w=h=0;
	return FALSE;
}
Пример #2
0
BOOL CNBUnitDevice::IsNotSynced()
{
	if(!IsGroup())
		return FALSE;
	if (GetRaidStatus() & NDAS_RAID_MEMBER_FLAG_OUT_OF_SYNC)
		return TRUE;
	else
		return FALSE;

//	return NDAS_UNIT_META_BIND_STATUS_NOT_SYNCED & m_RMD.UnitMetaData[m_cSequenceInRMD].UnitDeviceStatus;
}
Пример #3
0
BOOL CTreeOptionsCtrlEx::SetRadioButton(HTREEITEM hParent, int nIndex)
{
	//Validate our parameters
	ASSERT(IsGroup(hParent)); //Parent item must be a group item

	//Iterate through the child items and turn on the specified one and turn off all the other ones
	HTREEITEM hChild = GetNextItem(hParent, TVGN_CHILD);

	//Turn of redraw to Q all the changes we're going to make here
	SetRedraw(FALSE);

	int i=0;
	BOOL bCheckedSomeItem = FALSE;
	while (hChild)
	{
		//if we reach a non radio button then break out of the loop
		if (!IsRadioButton(hChild))
			break;

		if (i == nIndex)
		{
			//Turn this item on
			BOOL bOldState;
			GetRadioButton(hChild, bOldState);
			VERIFY(SetItemImage(hChild, 3, 3));
			bCheckedSomeItem = TRUE;
			if (!bOldState)
				NotifyParent(BN_CLICKED, hChild);
		}
		else
		{
			BOOL bEnable;
			VERIFY(GetRadioButtonEnable(hChild, bEnable));

			//Turn this item off
			if (bEnable)
				VERIFY(SetItemImage(hChild, 2, 2));
			else
				VERIFY(SetItemImage(hChild, 4, 4));
		}

		//Move on to the next item
		hChild = GetNextItem(hChild, TVGN_NEXT);
		++i;
	}
	ASSERT(bCheckedSomeItem); //You specified an index which does not exist

	//Reset the redraw flag
	SetRedraw(TRUE);

	return TRUE;
}
BOOL CTreeOptionsCtrlEx::SetRadioButton(HTREEITEM hItem)
{
	//Validate our parameters
	ASSERT(IsRadioButton(hItem)); //Must be a radio item to check it

	//Iterate through the sibling items and turn them all off except this one
	HTREEITEM hParent = GetNextItem(hItem, TVGN_PARENT);
	ASSERT(IsGroup(hParent)); //Parent item must be a group item

	//Iterate through the child items and turn on the specified one and turn off all the other ones
	HTREEITEM hChild = GetNextItem(hParent, TVGN_CHILD);

	//Turn of redraw to Q all the changes we're going to make here
	SetRedraw(FALSE);

	while (hChild)
	{
		//if we reach a non radio button then break out of the loop
		if (!IsRadioButton(hChild))
			break;

		if (hChild == hItem)
		{
			//Turn this item on
			BOOL bOldState;
			GetRadioButton(hChild, bOldState);
			BOOL bSuccess = SetItemImage(hChild, 3, 3);
			ASSERT(bSuccess);
			if (!bOldState)
				NotifyParent(BN_CLICKED, hChild);
		}
		else
		{
			BOOL bEnable;
			VERIFY(GetRadioButtonEnable(hChild, bEnable));

			//Turn this item off
			if (bEnable)
				VERIFY(SetItemImage(hChild, 2, 2));
			else
				VERIFY(SetItemImage(hChild, 6, 6));
		}

		//Move on to the next item
		hChild = GetNextItem(hChild, TVGN_NEXT);
	}

	//Reset the redraw flag
	SetRedraw(TRUE);

	return TRUE;
}
Пример #5
0
UINT64 CNBLogicalDevice::GetLogicalCapacityInByte()
{
	UINT64 size = 0;
	if(!IsGroup())
		return PrimaryUnitDevice()->GetLogicalCapacityInByte();

	switch(GetType())
	{
	case NMT_AGGREGATE:
		if (DevicesInRaid() != DevicesTotal(TRUE)) {
			// We need all disk's size to know total size.
			size = 0;
		} else {
			for(UINT32 i = 0; i < DevicesTotal(); i++)
			{
				if(m_mapUnitDevices.count(i)) {
					if (m_mapUnitDevices[i]->IsMissingMember()) {
						size =0;
						break;
					}
					size += m_mapUnitDevices[i]->GetLogicalCapacityInByte();
				} else {
					size = 0;
					break;
				}
			}
		}
		break;
	case NMT_RAID0:
		size = PrimaryUnitDevice()->GetLogicalCapacityInByte() * DevicesInRaid();
		break;
	case NMT_MIRROR:
	case NMT_RAID1:
	case NMT_RAID1R2:
	case NMT_RAID1R3:		
		size = PrimaryUnitDevice()->GetLogicalCapacityInByte();
		break;
	case NMT_RAID4:
	case NMT_RAID4R2:
	case NMT_RAID4R3:		
		size = PrimaryUnitDevice()->GetLogicalCapacityInByte() * (DevicesInRaid() -1);
		break;
	default:
		ATLASSERT(FALSE);
	}

	return size;
}
Пример #6
0
bool CContextMenuItem::Execute(const CFileItemPtr& item) const
{
  if (!item || m_library.empty() || IsGroup())
    return false;

  ADDON::AddonPtr addon;
  if (!CServiceBroker::GetAddonMgr().GetAddon(m_addonId, addon))
    return false;

#ifdef HAS_PYTHON
  LanguageInvokerPtr invoker(new CContextItemAddonInvoker(&g_pythonParser, item));
  return (CScriptInvocationManager::GetInstance().ExecuteAsync(m_library, invoker, addon) != -1);
#else
  return false;
#endif
}
Пример #7
0
void GetAwayMsgThread(LPVOID param)
{
	// Задержка чтобы миранда успела "переварить" ответ
	Sleep( 250 );

	ContactData* data = (ContactData*)param;

	bool ret = false;

	bool bGroup = IsGroup( data->hContact );
	CString sNick = GetNick( data->hContact );
	if ( ! bGroup && ! sNick.IsEmpty() )
	{
		ThreadEvent te = { CreateEvent( NULL, TRUE, FALSE, NULL ), data->cookie };

		// Отмечаемся в карте ожидающих нитей
		{
			CLock oLock( pluginGuard );
			pluginAwayThreadMap.SetAt( data->hContact, te );
		}

		// Асинхронный запрос эвей-сообщения
		ret = pluginNetBIOS.AskAway( netbios_name( sNick, 0x03, false ) );

		// Ожидание завершения (3 секунды)
		ret = ret && ( WaitForSingleObject( te.evt, 3000 ) == WAIT_OBJECT_0 );

		// Очистка карты ожидающих нитей
		{
			CLock oLock( pluginGuard );
			pluginAwayThreadMap.Lookup( data->hContact, te );
			pluginAwayThreadMap.RemoveKey( data->hContact );
		}

		CloseHandle( te.evt );
	}

	if ( ! ret )
	{
		// Уведомление о неудаче
		ProtoBroadcastAck (modname, data->hContact, ACKTYPE_AWAYMSG,
			ACKRESULT_SUCCESS /* ACKRESULT_FAILED */, data->cookie, (LPARAM)"" );
		LOG( "Get away message failed" );
	}

	delete data;
}
Пример #8
0
WTL::CString CNBLogicalDevice::GetIDString()
{
	WTL::CString strText;
	ATLASSERT(m_mapUnitDevices.size());

	if(IsGroup())
	{
		strText = _T("");
	}
	else
	{
		ATLASSERT(1 == m_mapUnitDevices.size() && m_mapUnitDevices.count(0));
		strText = AnyUnitDevice()->GetIDString();
	}

	return strText;
}
Пример #9
0
CString CNBLogicalDevice::GetIDString(TCHAR HiddenChar)
{
	CString strText;
	ATLASSERT(m_mapUnitDevices.size());

	if(IsGroup())
	{
		strText = _T("");
	}
	else
	{
		ATLASSERT(1 == m_mapUnitDevices.size() && m_mapUnitDevices.count(0));
		strText = PrimaryUnitDevice()->GetIDString(HiddenChar);
	}

	return strText;
}
Пример #10
0
CString CNBLogicalDevice::GetStatusString()
{
	CString strText;
	DWORD status = GetStatus();

	if (NDASBIND_LOGICAL_DEVICE_STATUS_DISCONNECTED & status) {
		strText.LoadString(IDS_STATUS_NOT_CONNECTED);
	} 
	else if (NDASBIND_LOGICAL_DEVICE_STATUS_DISABLED & status) {
		strText.LoadString(IDS_STATUS_DISABLED);
	} 
	else if (NDASBIND_LOGICAL_DEVICE_STATUS_NOT_REGISTERED & status) {
		strText.LoadString(IDS_STATUS_NOT_REGISTERED);
	}
	else if(NMT_INVALID == GetType())
	{
		// Maybe failed to connect inspite of reported as connected.
		// Safe to handle as if not connected?
		strText.LoadString(IDS_STATUS_NOT_CONNECTED);
	} 
	else if(NDASBIND_LOGICAL_DEVICE_STATUS_NO_WRITE_KEY & status)
	{
		strText.LoadString(IDS_STATUS_READ_ONLY);
	}
	else if(NDASBIND_LOGICAL_DEVICE_STATUS_MOUNTED & status)
	{
		strText.LoadString(IDS_STATUS_IN_USE);
	}
	else
	{
		if (IsGroup()) {
			if (m_RaidInfo.MountablityFlags & NDAS_RAID_MOUNTABILITY_MOUNTABLE)  {
				strText.LoadString(IDS_STATUS_FINE);
			} else {
				strText.LoadString(IDS_STATUS_UNMOUNTABLE);
			}
		} else {
			strText.LoadString(IDS_STATUS_FINE);
		}
	}
 
	return strText;
}
CXTPMarkupObject* CXTPMarkupKeyboardNavigation::GetGroupParent(CXTPMarkupObject* e, BOOL bIncludeCurrent)
{
	CXTPMarkupObject* obj2 = e;
	if (!bIncludeCurrent)
	{
		obj2 = e;
		e = GetParent(e);
		if (e == NULL)
		{
			return obj2;
		}
	}
	while (e != NULL)
	{
		if (IsGroup(e))
		{
			return e;
		}
		obj2 = e;
		e = GetParent(e);
	}
	return obj2;
}
Пример #12
0
UINT32 CNBLogicalDevice::DevicesTotal(BOOL bAliveOnly)
{
	ATLASSERT(m_mapUnitDevices.size());

	UINT32 total = 0;

	if(bAliveOnly)
	{		
		for(UINT32 i = 0; i < DevicesTotal(FALSE); i++)
		{
			if(m_mapUnitDevices.count(i))
			{
				total++;
			}
		}
	}
	else
	{
		total = (IsGroup()) ? DIB()->nDiskCount + DIB()->nSpareCount : 1;
	}

	return total;
}
Пример #13
0
WTL::CString CNBLogicalDevice::GetName()
{
	ATLASSERT(m_mapUnitDevices.size());

	WTL::CString strText;

	if(0 == m_mapUnitDevices.size())
	{
		strText.FormatMessage(IDS_LOGDEV_TYPE_UNKNOWN_FMT, NMT_INVALID);
	}
	else if(IsGroup())
	{
		strText = GetTypeString();
	}
	else
	{
		ATLASSERT(1 == m_mapUnitDevices.size() && m_mapUnitDevices.count(0));

		strText = m_mapUnitDevices[0]->GetName();
	}

	return strText;
}
CXTPMarkupObject* CXTPMarkupKeyboardNavigation::GetNextInTree(CXTPMarkupObject* e, CXTPMarkupObject* container)
{
	CXTPMarkupObject* firstChild = NULL;
	if ((e == container) || !IsGroup(e))
	{
		firstChild = GetTreeFirstChild(e);
	}
	if ((firstChild != NULL) || (e == container))
	{
		return firstChild;
	}
	CXTPMarkupObject* parent = e;
	do
	{
		CXTPMarkupObject* nextSibling = GetTreeNextSibling(parent);
		if (nextSibling != NULL)
		{
			return nextSibling;
		}
		parent = GetParent(parent);
	}
	while ((parent != NULL) && (parent != container));
	return NULL;
}
BOOL CXTPMarkupKeyboardNavigation::IsTabStopOrGroup(CXTPMarkupObject* e)
{
	return IsTabStop(e) || IsGroup(e);
}
Пример #16
0
UINT32 CNBUnitDevice::GetSequence()
{
	ATLASSERT(m_pLogicalDevice);

	return (IsGroup()) ? m_DIB.iSequence : 0;
}
Пример #17
0
BOOL CNBLogicalDevice::GetCommandAbility(int nID)
{
	if (IsGroup()) {
		switch(nID)
		{
		case IDM_TOOL_BIND:
			return TRUE;
		case IDM_TOOL_UNBIND:
			// Cannot unbind devices in use.
			return !(GetStatus() & NDASBIND_LOGICAL_DEVICE_STATUS_MOUNTED);
		case IDM_TOOL_ADDMIRROR:
			return FALSE;
		case IDM_TOOL_MIGRATE:
			return (
				IsHDD() && IsMigrationRequired() && IsOperatableAll() && !HasMissingMember());
		case IDM_TOOL_REPLACE_DEVICE:
			return FALSE;
		case IDM_TOOL_USE_AS_MEMBER:
			return FALSE;
		case IDM_TOOL_SPAREADD:
			return (IsFaultTolerant() && !IsMigrationRequired() && IsOperatableAll() && IsHealthy() && DevicesSpare(FALSE)==0);
		case IDM_TOOL_RESET_BIND_INFO:
			return FALSE;
		case IDM_TOOL_CLEAR_DEFECTIVE:
			return FALSE;
		case IDM_TOOL_USE_AS_BASIC:
			return FALSE;
		case IDM_TOOL_REMOVE_FROM_RAID:
			return FALSE;
		default:
			ATLASSERT(FALSE);
			return FALSE;
		}
	} else {
		// Basic disk type.
		switch(nID)
		{
		case IDM_TOOL_BIND:
			return TRUE;
		case IDM_TOOL_UNBIND:
			return FALSE;
		case IDM_TOOL_ADDMIRROR:
			return (IsHDD() && IsOperatableAll());
		case IDM_TOOL_MIGRATE:
			return FALSE;
		case IDM_TOOL_REPLACE_DEVICE:
			return FALSE;
		case IDM_TOOL_USE_AS_MEMBER:
			return FALSE;
		case IDM_TOOL_SPAREADD:
			return FALSE;
		case IDM_TOOL_RESET_BIND_INFO:
			return (IsHDD() && IsOperatable());
		case IDM_TOOL_CLEAR_DEFECTIVE:
			return FALSE;
		case IDM_TOOL_USE_AS_BASIC:
			return FALSE;
		case IDM_TOOL_REMOVE_FROM_RAID:
			return FALSE;
		default:
			ATLASSERT(FALSE);
			return FALSE;
		}
	}
	return FALSE;
}
Пример #18
0
DWORD CNBLogicalDevice::GetStatus()
{
	DWORD status = NULL, status_unit;

	if (IsGroup()){
		for(UINT32 i = 0; i < DevicesTotal(); i++)
		{
			status_unit = m_mapUnitDevices[i]->GetStatus();

			//
			// we don't need check disconnected status for RAID
			
			if(NDASBIND_UNIT_DEVICE_STATUS_DISABLED & status_unit)
			{
				status |= NDASBIND_LOGICAL_DEVICE_STATUS_DISABLED;
				continue;
			}

			if(NDASBIND_UNIT_DEVICE_STATUS_NO_WRITE_KEY & status_unit)
			{
				status |= NDASBIND_LOGICAL_DEVICE_STATUS_NO_WRITE_KEY;
			}

			if (m_mapUnitDevices[i]->IsMissingMember()) {
				// We don't care whether it is in use if it is current member.
				
			} else {
				if (NDASBIND_UNIT_DEVICE_STATUS_MOUNTED & status_unit)
				{
					status |= NDASBIND_LOGICAL_DEVICE_STATUS_MOUNTED;
				}
			}

			if (NDASBIND_UNIT_DEVICE_STATUS_NOT_REGISTERED & status_unit)
			{
				status |= NDASBIND_LOGICAL_DEVICE_STATUS_NOT_REGISTERED;
			}
		}

	} else {
		for(UINT32 i = 0; i < DevicesInRaid(); i++)
		{
			if(!m_mapUnitDevices.count(i))
			{
				status |= NDASBIND_LOGICAL_DEVICE_STATUS_DISCONNECTED;
				continue;
			}

			status_unit = m_mapUnitDevices[i]->GetStatus();

			if(NDASBIND_UNIT_DEVICE_STATUS_DISCONNECTED & status_unit)
			{
				status |= NDASBIND_LOGICAL_DEVICE_STATUS_DISCONNECTED;
				continue;
			}

			if(NDASBIND_UNIT_DEVICE_STATUS_DISABLED & status_unit)
			{
				status |= NDASBIND_LOGICAL_DEVICE_STATUS_DISABLED;
				continue;
			}

			if(NDASBIND_UNIT_DEVICE_STATUS_NO_WRITE_KEY & status_unit)
			{
				status |= NDASBIND_LOGICAL_DEVICE_STATUS_NO_WRITE_KEY;
			}

			if (NDASBIND_UNIT_DEVICE_STATUS_MOUNTED & status_unit)
			{
				status |= NDASBIND_LOGICAL_DEVICE_STATUS_MOUNTED;
			}
			if (NDASBIND_UNIT_DEVICE_STATUS_NOT_REGISTERED & status_unit)
			{
				status |= NDASBIND_LOGICAL_DEVICE_STATUS_NOT_REGISTERED;
			}
		}
	}
	return status;
}
Пример #19
0
bool CContextMenuItem::IsVisible(const CFileItemPtr& item) const
{
  return IsGroup() || (item && m_condition && m_condition->Get(item.get()));
}
Пример #20
0
UINT32 CNBUnitDevice::GetSequence()
{
//	ATLASSERT(m_pLogicalDevice);
	return (IsGroup()) ? m_SequenceInDib: 0;
}