#include <shellapi.h>
#include <commctrl.h>
#include <strsafe.h>

HINSTANCE g_hInst = NULL;

UINT const WMAPP_NOTIFYCALLBACK = WM_APP + 1;
UINT const WMAPP_HIDEFLYOUT     = WM_APP + 2;

UINT_PTR const HIDEFLYOUT_TIMER_ID = 1;

wchar_t const szWindowClass[] = L"NotificationIconTest";
wchar_t const szFlyoutWindowClass[] = L"NotificationFlyout";

// Use a guid to uniquely identify our icon
class __declspec(uuid("9D0B8B92-4E1C-488e-A1E1-2331AFCE2CB5")) PrinterIcon;

// Forward declarations of functions included in this code module:
void                RegisterWindowClass(PCWSTR pszClassName, PCWSTR pszMenuName, WNDPROC lpfnWndProc);
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
ATOM                RegisterFlyoutClass(HINSTANCE hInstance);
LRESULT CALLBACK    FlyoutWndProc(HWND, UINT, WPARAM, LPARAM);
HWND                ShowFlyout(HWND hwnd);
void                HideFlyout(HWND hwndMainWindow, HWND hwndFlyout);
void                PositionFlyout(HWND hwnd, REFGUID guidIcon);
void                ShowContextMenu(HWND hwnd, POINT pt);
BOOL                AddNotificationIcon(HWND hwnd);
BOOL                DeleteNotificationIcon();
BOOL                ShowLowInkBalloon();
BOOL                ShowNoInkBalloon();
BOOL                ShowPrintJobBalloon();
Esempio n. 2
0
 bool AnalysisObject_Impl::uuidAndVersionEqual(const AnalysisObject& other) const {
   return ((uuid() == other.uuid()) && (versionUUID() == other.versionUUID()));
 }
Esempio n. 3
0
bool WebPage::matchesWindowSelector(QString selector) {
  return (selector == getWindowName()           ||
      selector == mainFrame()->title()          ||
      selector == mainFrame()->url().toString() ||
      selector == uuid());
}
Esempio n. 4
0
void pyVaultNode::SetCreateAgeGuid( const char * v )
{
    ASSERT(fNode);
    plUUID uuid(v);
    fNode->SetCreateAgeUuid(uuid);
}
Esempio n. 5
0
bool
Lorica::Config::Endpoint::parse_string(const std::string &ep_str,
                                       const bool outside_facing)
{
        this->is_ipv6_ = false;
        this->ssl_port_ = 0;

        size_t option_pos = ep_str.find('/');
        std::string primary_addr = (option_pos != std::string::npos) ? ep_str.substr(0,option_pos) : ep_str;

        size_t port_sep = primary_addr.rfind(':');
        if (port_sep == std::string::npos) {
                ACE_ERROR((LM_ERROR,
                           "%N:%l - configured endpoint \"%s\" lacks port separator\n",
                           primary_addr.c_str()));
                return false;
        }

        this->port_ = static_cast<int> (ACE_OS::strtol(primary_addr.substr(port_sep+1).c_str(), 0, 10));
        if (0 >= this->port_) {
                if (outside_facing)
                        this->port_ = LORICA_DEFAULT_OUTSIDE_FACING_PORT;
                else
                        this->port_ = LORICA_DEFAULT_INSIDE_FACING_PORT;
        }

        size_t start = 0;
        size_t end = port_sep;

        // "[]:123" and ":123" are both accepted
        if (!port_sep) {
                this->hostname_ = "";
        } else if ((2 == port_sep)
                   && ((primary_addr[0] == '[') && (primary_addr[1] == ']'))) {
                this->is_ipv6_ = true;
                this->hostname_ = "";
        } else {
                if ((primary_addr[start] == '[') && (primary_addr[end-1] == ']')) {
                        this->is_ipv6_ = true;
                        ++start;
                        end -= 2;
                }
                this->hostname_ = primary_addr.substr(start, end);
        }

        // IPv4 - check for the interface name extension
        if (!this->hostname_.empty() && '%' == this->hostname_[0]) {
                std::string ifname = this->hostname_.substr(1);
                
                if (ifname.empty()) {
                        this->hostname_ = "";
                } else {
                        while (true) {
                                char *ip_addr = NULL;
                                if ('?' == this->hostname_[1])
                                        ip_addr = get_first_external_ip(AF_INET);
                                else
                                        ip_addr = get_ip_from_ifname(AF_INET, ifname.c_str());

                                this->hostname_ = ip_addr ? (const char*)ip_addr : "";
                                if (ip_addr) {
                                        ACE_DEBUG((LM_INFO, 
                                                   ACE_TEXT("%N:%l - Autodetected address for ")
                                                   ACE_TEXT("IPv4 endpoint on %s - %s\n"), 
                                                   ACE_TEXT_CHAR_TO_TCHAR(ifname.c_str()),
                                                   ACE_TEXT_CHAR_TO_TCHAR(this->hostname_.c_str())));
                                        free(ip_addr);
                                        break;
                                } 
                                ACE_DEBUG((LM_WARNING, 
                                           ACE_TEXT("%N:%l - Could not determine auto address for ")
                                           ACE_TEXT("this IPv4 NIC - %s. Retrying in 10 seconds...\n"),
                                           ACE_TEXT_CHAR_TO_TCHAR(ifname.c_str())));
                                ACE_OS::sleep(10); 
                        }
		}
        }

        // IPv6 - check for the interface name extension
        if (!this->hostname_.empty() && '+' == this->hostname_[0]) {
                std::string ifname = this->hostname_.substr(1);

                this->is_ipv6_ = true;
                
                if (ifname.empty()) {
                        this->hostname_ = "";
		} else {
			while (true) {
                                char *ip_addr = NULL;
                                if ('?' == this->hostname_[1])
                                        ip_addr = get_first_external_ip(AF_INET6);
                                else
                                        ip_addr = get_ip_from_ifname(AF_INET6, ifname.c_str());

                                this->hostname_ = ip_addr ? (const char*)ip_addr : "";
                                if (ip_addr) {
                                        ACE_DEBUG((LM_INFO,
                                                   ACE_TEXT("%N:%l - Autodetected address for ")
                                                   ACE_TEXT("IPv6 endpoint on %s - %s\n"),
                                                   ACE_TEXT_CHAR_TO_TCHAR(ifname.c_str()),
                                                   ACE_TEXT_CHAR_TO_TCHAR(this->hostname_.c_str())));
                                        free(ip_addr);
                                        break;
                                }
                                ACE_DEBUG((LM_WARNING,
                                           ACE_TEXT("%N:%l - Could not determine auto address for ")
                                           ACE_TEXT("this IPv6 NIC - %s. Retrying in 10 seconds...\n"),
                                           ACE_TEXT_CHAR_TO_TCHAR(ifname.c_str())));
                                ACE_OS::sleep(10);
                        }
		}
        }

        // check for empty hostname and fix it up so that
        // we don't throw the MProfile exception
        if (this->hostname_.empty()) {
                char host_name[HOST_NAME_MAX] = { '\0' };

                ACE_OS::hostname(host_name, sizeof(host_name));
                this->hostname_ = (const char*)host_name;

                ACE_DEBUG((LM_WARNING, 
                           ACE_TEXT("%N:%l - DEPRECATED: Using default ")
                           ACE_TEXT("hostname for %s facing endpoint - %s\n"),
                           outside_facing ? ACE_TEXT("outside") : ACE_TEXT("inside"),
                           ACE_TEXT_CHAR_TO_TCHAR(this->hostname_.c_str())));
        }

        if (option_pos != std::string::npos) {
                // The rest are optional modifiers, ssl port, hostname alias
                ++option_pos;

                std::string test("alias=");
                size_t opt = ep_str.find (test, option_pos);
                if (opt != std::string::npos) {
                        size_t comma = ep_str.find (',',opt);
                        size_t begin = opt + test.length();

                        this->alias_ = (comma == std::string::npos) ? ep_str.substr(begin) : ep_str.substr(begin, comma - begin);
                } 

		test = "random_alias";
		opt = ep_str.find (test, option_pos);
		if (opt != std::string::npos) {
			test = "alias=";
			opt = ep_str.find (test, option_pos);
			if (opt != std::string::npos) {
                                ACE_DEBUG((LM_ERROR,
                                           ACE_TEXT("%N:%l - Both random_alias and alias, which are mutually exclusive, are used\n")));
				return false;
			}
			ACE_Utils::UUID uuid(*ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID());
			const ACE_CString *uuid_str(uuid.to_string());
			this->alias_ = uuid_str->c_str();
		}		

                test = "ssl_port=";
                opt = ep_str.find (test, option_pos);
                if (opt != std::string::npos) {
                        size_t comma = ep_str.find (',',opt);
                        size_t begin = opt + test.length();

                        std::string portstr = (comma == std::string::npos) ? ep_str.substr(begin) : ep_str.substr(begin, comma - begin);
                        this->ssl_port_ = static_cast<int> (ACE_OS::strtol(portstr.c_str(), 0, 10));
                        if (0 >= this->ssl_port_) {
                                if (outside_facing)
                                        this->ssl_port_ = LORICA_DEFAULT_OUTSIDE_FACING_PORT_SEC;
                                else
                                        this->ssl_port_ = LORICA_DEFAULT_INSIDE_FACING_PORT_SEC;
                        }
                }
        }

        return true;
}
Esempio n. 6
0
void
MediaEngineWebRTC::EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSource> >* aASources)
{
  ScopedCustomReleasePtr<webrtc::VoEBase> ptrVoEBase;
  ScopedCustomReleasePtr<webrtc::VoEHardware> ptrVoEHw;
  // We spawn threads to handle gUM runnables, so we must protect the member vars
  MutexAutoLock lock(mMutex);

#ifdef MOZ_WIDGET_ANDROID
  jobject context = mozilla::AndroidBridge::Bridge()->GetGlobalContextRef();

  // get the JVM
  JavaVM *jvm = mozilla::AndroidBridge::Bridge()->GetVM();
  JNIEnv *env = GetJNIForThread();

  if (webrtc::VoiceEngine::SetAndroidObjects(jvm, env, (void*)context) != 0) {
    LOG(("VoiceEngine:SetAndroidObjects Failed"));
    return;
  }
#endif

  if (!mVoiceEngine) {
    mVoiceEngine = webrtc::VoiceEngine::Create();
    if (!mVoiceEngine) {
      return;
    }
  }

  PRLogModuleInfo *logs = GetWebRTCLogInfo();
  if (!gWebrtcTraceLoggingOn && logs && logs->level > 0) {
    // no need to a critical section or lock here
    gWebrtcTraceLoggingOn = 1;

    const char *file = PR_GetEnv("WEBRTC_TRACE_FILE");
    if (!file) {
      file = "WebRTC.log";
    }

    LOG(("Logging webrtc to %s level %d", __FUNCTION__, file, logs->level));

    mVoiceEngine->SetTraceFilter(logs->level);
    mVoiceEngine->SetTraceFile(file);
  }

  ptrVoEBase = webrtc::VoEBase::GetInterface(mVoiceEngine);
  if (!ptrVoEBase) {
    return;
  }

  if (!mAudioEngineInit) {
    if (ptrVoEBase->Init() < 0) {
      return;
    }
    mAudioEngineInit = true;
  }

  ptrVoEHw = webrtc::VoEHardware::GetInterface(mVoiceEngine);
  if (!ptrVoEHw)  {
    return;
  }

  int nDevices = 0;
  ptrVoEHw->GetNumOfRecordingDevices(nDevices);
  for (int i = 0; i < nDevices; i++) {
    // We use constants here because GetRecordingDeviceName takes char[128].
    char deviceName[128];
    char uniqueId[128];
    // paranoia; jingle doesn't bother with this
    deviceName[0] = '\0';
    uniqueId[0] = '\0';

    int error = ptrVoEHw->GetRecordingDeviceName(i, deviceName, uniqueId);
    if (error) {
      LOG((" VoEHardware:GetRecordingDeviceName: Failed %d",
           ptrVoEBase->LastError() ));
      continue;
    }

    if (uniqueId[0] == '\0') {
      // Mac and Linux don't set uniqueId!
      MOZ_ASSERT(sizeof(deviceName) == sizeof(uniqueId)); // total paranoia
      strcpy(uniqueId,deviceName); // safe given assert and initialization/error-check
    }

    nsRefPtr<MediaEngineWebRTCAudioSource> aSource;
    NS_ConvertUTF8toUTF16 uuid(uniqueId);
    if (mAudioSources.Get(uuid, getter_AddRefs(aSource))) {
      // We've already seen this device, just append.
      aASources->AppendElement(aSource.get());
    } else {
      aSource = new MediaEngineWebRTCAudioSource(
        mVoiceEngine, i, deviceName, uniqueId
      );
      mAudioSources.Put(uuid, aSource); // Hashtable takes ownership.
      aASources->AppendElement(aSource);
    }
  }
}
Esempio n. 7
0
static va_list
convertNativeToTclObject (va_list pArg,
                          Tcl_Interp *interp,
                          TclObject &tclObject,
                          const Type &type,
                          bool byRef=false)
{
    switch (type.vartype()) {
    case VT_BOOL:
        tclObject = Tcl_NewBooleanObj(
            byRef ? *va_arg(pArg, VARIANT_BOOL *) : va_arg(pArg, VARIANT_BOOL));
        break;

    case VT_DATE:
    case VT_R4:
    case VT_R8:
        tclObject = Tcl_NewDoubleObj(
            byRef ? *va_arg(pArg, double *) : va_arg(pArg, double));
        break;

    case VT_USERDEFINED:
        if (type.name() == "GUID") {
            UUID *pUuid = va_arg(pArg, UUID *);
            Uuid uuid(*pUuid);
            tclObject = Tcl_NewStringObj(
                const_cast<char *>(uuid.toString().c_str()), -1);
            break;
        }
        // Fall through

    case VT_DISPATCH:
    case VT_UNKNOWN:
        {
            IUnknown *pUnknown = va_arg(pArg, IUnknown *);
            if (pUnknown == 0) {
                tclObject = Tcl_NewObj();
            } else {
                const Interface *pInterface =
                    InterfaceManager::instance().find(type.iid());
                tclObject = Extension::referenceHandles.newObj(
                    interp, Reference::newReference(pUnknown, pInterface));
            }
        }
        break;

    case VT_NULL:
        tclObject = Tcl_NewObj();
        break;

    case VT_LPWSTR:
    case VT_BSTR:
        {
#if TCL_MINOR_VERSION >= 2
            // Uses Unicode function introduced in Tcl 8.2.
            Tcl_UniChar *pUnicode = byRef ?
                *va_arg(pArg, Tcl_UniChar **) : va_arg(pArg, Tcl_UniChar *);
            if (pUnicode != 0) {
                tclObject = Tcl_NewUnicodeObj(pUnicode, -1);
            } else {
                tclObject = Tcl_NewObj();
            }
#else
            wchar_t *pUnicode = byRef ?
                *va_arg(pArg, wchar_t **) : va_arg(pArg, wchar_t *);
            _bstr_t str(pUnicode);
            tclObject = Tcl_NewStringObj(str, -1);
#endif
        }
        break;

    case VT_VARIANT:
        tclObject = TclObject(
            byRef ? va_arg(pArg, VARIANT *) : &va_arg(pArg, VARIANT),
            type,
            interp);
        break;

    case VT_SAFEARRAY:
        tclObject = TclObject(
            byRef ? *va_arg(pArg, SAFEARRAY **) : va_arg(pArg, SAFEARRAY *),
            type,
            interp);
        break;

    default:
        tclObject = Tcl_NewLongObj(
            byRef ? *va_arg(pArg, int *) : va_arg(pArg, int));
    }
Esempio n. 8
0
int
Tester::test (void)
{
  int retval = 0;

  // Generate UUID
  auto_ptr <ACE_Utils::UUID> uuid (ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID ());
  ACE_CString uuid_str (uuid->to_string ()->c_str ());
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Generated UUID\n %C\n"),
              uuid_str.c_str ()));

  // Construct UUID from string
  ACE_Utils::UUID new_uuid (uuid_str);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("UUID Constructed from above Generated UUID\n %C\n"),
              new_uuid.to_string ()->c_str ()));

  // Construct UUID from string by assigning it
  ACE_Utils::UUID new_uuid_assign;
  new_uuid_assign.from_string (new_uuid.to_string ()->c_str ());
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("UUID Constructed from above Generated UUID ")
              ACE_TEXT ("with assign\n %C\n"),
              new_uuid_assign.to_string ()->c_str ()));

  if (new_uuid != new_uuid_assign)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Error: UUIDs are not the same\n")),
                       -1);

  // Check the hash value of the 2 UUIDs

  if (new_uuid.hash () != new_uuid_assign.hash ())
    ACE_ERROR_RETURN ((LM_ERROR,
                        ACE_TEXT ("Error: hash value of UUIDs are ")
                        ACE_TEXT ("not the same")),
                        -1);

  // Construct UUID using the copy constructor
  ACE_Utils::UUID new_uuid_copy (new_uuid);
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("UUID constructed from above Generated UUID")
              ACE_TEXT (" with copy\n %C\n"),
              new_uuid_copy.to_string ()->c_str ()));

  if (new_uuid != new_uuid_copy)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Error: UUIDs are not the same ")
                       ACE_TEXT ("with copy\n")),
                       -1);

  ACE_Utils::UUID nil_uuid (*ACE_Utils::UUID::NIL_UUID.to_string ());
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("UUID Constructed from NIL_UUID with ")
              ACE_TEXT ("string copy\n %C\n"),
              nil_uuid.to_string ()->c_str ()));

  if (nil_uuid != ACE_Utils::UUID::NIL_UUID)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Error: UUIDs are not the same with ")
                       ACE_TEXT ("NIL_UUID string copy\n")),
                       -1);

  // Construct UUID using the assignment constructor
  ACE_Utils::UUID new_uuid_assigment;
  new_uuid_assigment = new_uuid;
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("UUID Constructed from above Generated UUID ")
              ACE_TEXT ("with assignment\n %C\n"),
              new_uuid_assigment.to_string ()->c_str ()));

  if (new_uuid != new_uuid_assigment)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Error: UUIDs are not the same "
                       ACE_TEXT ("with assignment\n"))),
                       -1);

  // Generate UUID with process and thread ids.
  auto_ptr <ACE_Utils::UUID>
    uuid_with_tp_id (ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (0x0001, 0xc0));

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("UUID with Thread and Process ID\n %C\n"),
              uuid_with_tp_id->to_string ()->c_str ()));

  if (new_uuid == *uuid_with_tp_id)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Error: UUIDs are the same\n")),
                       -1);

  // Construct UUID from string
  ACE_Utils::UUID new_uuid_with_tp_id (uuid_with_tp_id->to_string ()->c_str ());
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("UUID with Thread and Process ID reconstructed ")
              ACE_TEXT ("from above UUID \n %C\n"),
              new_uuid_with_tp_id.to_string ()->c_str ()));

  return retval;
}
Esempio n. 9
0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.

#include "pch.h"
#include <Vector.h>

namespace ABI {
    namespace Windows {
        namespace Foundation {
            namespace Collections
            {
                template<> struct __declspec(uuid("b939af5b-b45d-5489-9149-61442c1905fe")) IVector<int>     : IVector_impl    <int> { };
                template<> struct __declspec(uuid("8d720cdf-3934-5d3f-9a55-40e8063b086a")) IVectorView<int> : IVectorView_impl<int> { };
                template<> struct __declspec(uuid("81a643fb-f51c-5565-83c4-f96425777b66")) IIterable<int>   : IIterable_impl  <int> { };
                template<> struct __declspec(uuid("bfea7f78-50c2-5f1d-a6ea-9e978d2699ff")) IIterator<int>   : IIterator_impl  <int> { };
            }
        }
    }
}

namespace NativeComponent
{
    using namespace Windows::Foundation::Collections;
    using namespace Microsoft::WRL;
    using namespace collections;

    public ref class VectorCreator sealed
    {
Esempio n. 10
0
//

CStreamSwitcherInputPin::CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr, LPCWSTR pName)
    : CBaseInputPin(NAME("CStreamSwitcherInputPin"), pFilter, &pFilter->m_csState, phr, pName)
    , m_Allocator(this, phr)
    , m_bSampleSkipped(FALSE)
    , m_bQualityChanged(FALSE)
    , m_bUsingOwnAllocator(FALSE)
    , m_evBlock(TRUE)
    , m_fCanBlock(false)
    , m_hNotifyEvent(NULL)
{
    m_bCanReconnectWhenActive = TRUE;
}

class __declspec(uuid("138130AF-A79B-45D5-B4AA-87697457BA87"))
        NeroAudioDecoder {};

STDMETHODIMP CStreamSwitcherInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
    return
        QI(IStreamSwitcherInputPin)
        IsConnected() && GetCLSID(GetFilterFromPin(GetConnected())) == __uuidof(NeroAudioDecoder) && QI(IPinConnection)
        __super::NonDelegatingQueryInterface(riid, ppv);
}

// IPinConnection

STDMETHODIMP CStreamSwitcherInputPin::DynamicQueryAccept(const AM_MEDIA_TYPE* pmt)
{
    return QueryAccept(pmt);
#include "global.h"
#include "MovieTexture_DShowHelper.h"
#include "RageUtil.h"
#include "RageLog.h"
#include "archutils/Win32/DirectXHelpers.h"

//-----------------------------------------------------------------------------
// Define GUID for Texture Renderer
// {71771540-2017-11cf-AE26-0020AFD79767}
//-----------------------------------------------------------------------------
struct __declspec(uuid("{71771540-2017-11cf-ae26-0020afd79767}")) CLSID_TextureRenderer;

static HRESULT CBV_ret;
CTextureRenderer::CTextureRenderer():
    CBaseVideoRenderer(__uuidof(CLSID_TextureRenderer),
                       NAME("Texture Renderer"), NULL, &CBV_ret),
    m_OneFrameDecoded( "m_OneFrameDecoded", 0 )
{
    if( FAILED(CBV_ret) )
        RageException::Throw( hr_ssprintf(CBV_ret, "Could not create texture renderer object!") );

    m_pTexture = NULL;
}

CTextureRenderer::~CTextureRenderer()
{
}


HRESULT CTextureRenderer::CheckMediaType(const CMediaType *pmt)
{
Esempio n. 12
0
void RlvFloaterBehaviour::refreshAll()
{
	LLVOAvatar* pAvatar = gAgent.getAvatarObject();
	LLCtrlListInterface* pList = childGetListInterface("behaviour_list");
	const rlv_object_map_t* pRlvObjects = gRlvHandler.getObjectMap();
	if ( (!pAvatar) || (!pList) || (!pRlvObjects) )
		return;

	pList->operateOnAll(LLCtrlListInterface::OP_DELETE);

	for (rlv_object_map_t::const_iterator itObj = pRlvObjects->begin(), endObj = pRlvObjects->end(); itObj != endObj; ++itObj)
	{
		std::string strName = itObj->first.asString();

		LLViewerInventoryItem* pItem = NULL;
		LLViewerObject* pObj = gObjectList.findObject(itObj->first);
		if (pObj)
		{
			LLViewerJointAttachment* pAttachPt = 
				get_if_there(pAvatar->mAttachmentPoints, gRlvHandler.getAttachPointIndex(pObj), (LLViewerJointAttachment*)NULL);
			if (pAttachPt)
			{
				pItem = gInventory.getItem(pAttachPt->getItemID());
			}
		}

		if (pItem)
			strName = pItem->getName();

		const rlv_command_list_t* pCommands = itObj->second.getCommandList();
		for (rlv_command_list_t::const_iterator itCmd = pCommands->begin(), endCmd = pCommands->end(); itCmd != endCmd; ++itCmd)
		{
			std::string strBhvr = itCmd->asString(); LLUUID uuid(itCmd->getOption());
			if (uuid.notNull())
			{
				std::string strLookup;
				if ( (gCacheName->getFullName(uuid, strLookup)) || (gCacheName->getGroupName(uuid, strLookup)) )
				{
					if (strLookup.find("???") == std::string::npos)
						strBhvr.assign(itCmd->getBehaviour()).append(":").append(strLookup);
				}
				else if (m_PendingLookup.end() == std::find(m_PendingLookup.begin(), m_PendingLookup.end(), uuid))
				{
					gCacheName->get(uuid, FALSE, onAvatarNameLookup, this);
					m_PendingLookup.push_back(uuid);
				}
			}

			LLSD element;

			// Restriction column
			element["columns"][0]["column"] = "behaviour";
			element["columns"][0]["value"] = strBhvr;
			element["columns"][0]["font"] = "SANSSERIF";
			element["columns"][0]["font-style"] = "NORMAL";

			// Object Name column
			element["columns"][1]["column"] = "name";
			element["columns"][1]["value"] = strName;
			element["columns"][1]["font"] = "SANSSERIF";
			element["columns"][1]["font-style"] = "NORMAL";

			pList->addElement(element, ADD_BOTTOM);
		}
	}
}
Esempio n. 13
0
void
MediaEngineWebRTC::EnumerateAudioDevices(dom::MediaSourceEnum aMediaSource,
                                         nsTArray<RefPtr<MediaEngineAudioSource> >* aASources)
{
  ScopedCustomReleasePtr<webrtc::VoEBase> ptrVoEBase;
  // We spawn threads to handle gUM runnables, so we must protect the member vars
  MutexAutoLock lock(mMutex);

  if (aMediaSource == dom::MediaSourceEnum::AudioCapture) {
    RefPtr<MediaEngineWebRTCAudioCaptureSource> audioCaptureSource =
      new MediaEngineWebRTCAudioCaptureSource(nullptr);
    aASources->AppendElement(audioCaptureSource);
    return;
  }

#ifdef MOZ_WIDGET_ANDROID
  jobject context = mozilla::AndroidBridge::Bridge()->GetGlobalContextRef();

  // get the JVM
  JavaVM* jvm;
  JNIEnv* const env = jni::GetEnvForThread();
  MOZ_ALWAYS_TRUE(!env->GetJavaVM(&jvm));

  if (webrtc::VoiceEngine::SetAndroidObjects(jvm, (void*)context) != 0) {
    LOG(("VoiceEngine:SetAndroidObjects Failed"));
    return;
  }
#endif

  if (!mVoiceEngine) {
    mConfig.Set<webrtc::ExtendedFilter>(new webrtc::ExtendedFilter(mExtendedFilter));
    mConfig.Set<webrtc::DelayAgnostic>(new webrtc::DelayAgnostic(mDelayAgnostic));

    mVoiceEngine = webrtc::VoiceEngine::Create(mConfig);
    if (!mVoiceEngine) {
      return;
    }
  }

  ptrVoEBase = webrtc::VoEBase::GetInterface(mVoiceEngine);
  if (!ptrVoEBase) {
    return;
  }

  // Always re-init the voice engine, since if we close the last use we
  // DeInitEngine() and Terminate(), which shuts down Process() - but means
  // we have to Init() again before using it.  Init() when already inited is
  // just a no-op, so call always.
  if (ptrVoEBase->Init() < 0) {
    return;
  }

  if (!mAudioInput) {
    if (SupportsDuplex()) {
      // The platform_supports_full_duplex.
      mAudioInput = new mozilla::AudioInputCubeb(mVoiceEngine);
    } else {
      mAudioInput = new mozilla::AudioInputWebRTC(mVoiceEngine);
    }
  }

  int nDevices = 0;
  mAudioInput->GetNumOfRecordingDevices(nDevices);
  int i;
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
  i = 0; // Bug 1037025 - let the OS handle defaulting for now on android/b2g
#else
  // -1 is "default communications device" depending on OS in webrtc.org code
  i = -1;
#endif
  for (; i < nDevices; i++) {
    // We use constants here because GetRecordingDeviceName takes char[128].
    char deviceName[128];
    char uniqueId[128];
    // paranoia; jingle doesn't bother with this
    deviceName[0] = '\0';
    uniqueId[0] = '\0';

    int error = mAudioInput->GetRecordingDeviceName(i, deviceName, uniqueId);
    if (error) {
      LOG((" VoEHardware:GetRecordingDeviceName: Failed %d", error));
      continue;
    }

    if (uniqueId[0] == '\0') {
      // Mac and Linux don't set uniqueId!
      MOZ_ASSERT(sizeof(deviceName) == sizeof(uniqueId)); // total paranoia
      strcpy(uniqueId, deviceName); // safe given assert and initialization/error-check
    }

    RefPtr<MediaEngineAudioSource> aSource;
    NS_ConvertUTF8toUTF16 uuid(uniqueId);
    if (mAudioSources.Get(uuid, getter_AddRefs(aSource))) {
      // We've already seen this device, just append.
      aASources->AppendElement(aSource.get());
    } else {
      AudioInput* audioinput = mAudioInput;
      if (SupportsDuplex()) {
        // The platform_supports_full_duplex.

        // For cubeb, it has state (the selected ID)
        // XXX just use the uniqueID for cubeb and support it everywhere, and get rid of this
        // XXX Small window where the device list/index could change!
        audioinput = new mozilla::AudioInputCubeb(mVoiceEngine, i);
      }
      aSource = new MediaEngineWebRTCMicrophoneSource(mVoiceEngine, audioinput,
                                                      i, deviceName, uniqueId);
      mAudioSources.Put(uuid, aSource); // Hashtable takes ownership.
      aASources->AppendElement(aSource);
    }
  }
}
Esempio n. 14
0
void
MediaEngineWebRTC::EnumerateVideoDevices(dom::MediaSourceEnum aMediaSource,
                                         nsTArray<RefPtr<MediaEngineVideoSource> >* aVSources)
{
  // We spawn threads to handle gUM runnables, so we must protect the member vars
  MutexAutoLock lock(mMutex);

#if defined(MOZ_B2G_CAMERA) && defined(MOZ_WIDGET_GONK)
  if (aMediaSource != dom::MediaSourceEnum::Camera) {
    // only supports camera sources
    return;
  }

  /**
   * We still enumerate every time, in case a new device was plugged in since
   * the last call. TODO: Verify that WebRTC actually does deal with hotplugging
   * new devices (with or without new engine creation) and accordingly adjust.
   * Enumeration is not neccessary if GIPS reports the same set of devices
   * for a given instance of the engine. Likewise, if a device was plugged out,
   * mVideoSources must be updated.
   */
  int num = 0;
  nsresult result;
  result = ICameraControl::GetNumberOfCameras(num);
  if (num <= 0 || result != NS_OK) {
    return;
  }

  for (int i = 0; i < num; i++) {
    nsCString cameraName;
    result = ICameraControl::GetCameraName(i, cameraName);
    if (result != NS_OK) {
      continue;
    }

    RefPtr<MediaEngineVideoSource> vSource;
    NS_ConvertUTF8toUTF16 uuid(cameraName);
    if (mVideoSources.Get(uuid, getter_AddRefs(vSource))) {
      // We've already seen this device, just append.
      aVSources->AppendElement(vSource.get());
    } else {
      vSource = new MediaEngineGonkVideoSource(i);
      mVideoSources.Put(uuid, vSource); // Hashtable takes ownership.
      aVSources->AppendElement(vSource);
    }
  }

  return;
#else
  mozilla::camera::CaptureEngine capEngine = mozilla::camera::InvalidEngine;

#ifdef MOZ_WIDGET_ANDROID
  // get the JVM
  JavaVM* jvm;
  JNIEnv* const env = jni::GetEnvForThread();
  MOZ_ALWAYS_TRUE(!env->GetJavaVM(&jvm));

  if (webrtc::VideoEngine::SetAndroidObjects(jvm) != 0) {
    LOG(("VieCapture:SetAndroidObjects Failed"));
    return;
  }
#endif

  switch (aMediaSource) {
    case dom::MediaSourceEnum::Window:
      capEngine = mozilla::camera::WinEngine;
      break;
    case dom::MediaSourceEnum::Application:
      capEngine = mozilla::camera::AppEngine;
      break;
    case dom::MediaSourceEnum::Screen:
      capEngine = mozilla::camera::ScreenEngine;
      break;
    case dom::MediaSourceEnum::Browser:
      capEngine = mozilla::camera::BrowserEngine;
      break;
    case dom::MediaSourceEnum::Camera:
      capEngine = mozilla::camera::CameraEngine;
      break;
    default:
      // BOOM
      MOZ_CRASH("No valid video engine");
      break;
  }

  /**
   * We still enumerate every time, in case a new device was plugged in since
   * the last call. TODO: Verify that WebRTC actually does deal with hotplugging
   * new devices (with or without new engine creation) and accordingly adjust.
   * Enumeration is not neccessary if GIPS reports the same set of devices
   * for a given instance of the engine. Likewise, if a device was plugged out,
   * mVideoSources must be updated.
   */
  int num;
  num = mozilla::camera::GetChildAndCall(
    &mozilla::camera::CamerasChild::NumberOfCaptureDevices,
    capEngine);

  for (int i = 0; i < num; i++) {
    char deviceName[MediaEngineSource::kMaxDeviceNameLength];
    char uniqueId[MediaEngineSource::kMaxUniqueIdLength];

    // paranoia
    deviceName[0] = '\0';
    uniqueId[0] = '\0';
    int error;

    error =  mozilla::camera::GetChildAndCall(
      &mozilla::camera::CamerasChild::GetCaptureDevice,
      capEngine,
      i, deviceName,
      sizeof(deviceName), uniqueId,
      sizeof(uniqueId));
    if (error) {
      LOG(("camera:GetCaptureDevice: Failed %d", error ));
      continue;
    }
#ifdef DEBUG
    LOG(("  Capture Device Index %d, Name %s", i, deviceName));

    webrtc::CaptureCapability cap;
    int numCaps = mozilla::camera::GetChildAndCall(
      &mozilla::camera::CamerasChild::NumberOfCapabilities,
      capEngine,
      uniqueId);
    LOG(("Number of Capabilities %d", numCaps));
    for (int j = 0; j < numCaps; j++) {
      if (mozilla::camera::GetChildAndCall(
            &mozilla::camera::CamerasChild::GetCaptureCapability,
            capEngine,
            uniqueId,
            j, cap) != 0) {
       break;
      }
      LOG(("type=%d width=%d height=%d maxFPS=%d",
           cap.rawType, cap.width, cap.height, cap.maxFPS ));
    }
#endif

    if (uniqueId[0] == '\0') {
      // In case a device doesn't set uniqueId!
      strncpy(uniqueId, deviceName, sizeof(uniqueId));
      uniqueId[sizeof(uniqueId)-1] = '\0'; // strncpy isn't safe
    }

    RefPtr<MediaEngineVideoSource> vSource;
    NS_ConvertUTF8toUTF16 uuid(uniqueId);
    if (mVideoSources.Get(uuid, getter_AddRefs(vSource))) {
      // We've already seen this device, just refresh and append.
      static_cast<MediaEngineRemoteVideoSource*>(vSource.get())->Refresh(i);
      aVSources->AppendElement(vSource.get());
    } else {
      vSource = new MediaEngineRemoteVideoSource(i, capEngine, aMediaSource);
      mVideoSources.Put(uuid, vSource); // Hashtable takes ownership.
      aVSources->AppendElement(vSource);
    }
  }

  if (mHasTabVideoSource || dom::MediaSourceEnum::Browser == aMediaSource) {
    aVSources->AppendElement(new MediaEngineTabVideoSource());
  }
#endif
}
Esempio n. 15
0
// Checks cache entries and removes invalid ones from the index file
void Cache::check(bool force)
{
	std::map<std::string, std::pair<uint32_t, uint32_t> > index;

	std::string path = cacheDir();
	PDEBUG << "Checking cache in dir: " << path << endl;

	bool created;
	checkDir(path, &created);
	if (created) {
		Logger::info() << "Cache: Created empty cache for '" << uuid() << '\'' << endl;
		return;
	}
	sys::datetime::Watch watch;

	GZIStream *in = new GZIStream(path+"/index");
	if (!in->ok()) {
		Logger::info() << "Cache: Empty cache for '" << uuid() << '\'' << endl;
		delete in;
		return;
	}

	BIStream *cache_in = NULL;
	uint32_t cache_index = -1;

	uint32_t version;
	*in >> version;
	switch (checkVersion(version)) {
		case OutOfDate:
			delete in;
			Logger::warn() << "Cache: Cache is out of date";
			if (!force) {
				Logger::warn() << " - won't clear it until forced to do so" << endl;
			} else {
				Logger::warn() << ", clearing" << endl;
				clear();
			}
			return;
		case UnknownVersion:
			delete in;
			Logger::warn() << "Cache: Unknown cache version number " << version;
			if (!force) {
				Logger::warn() << " - won't clear it until forced to do so" << endl;
			} else {
				Logger::warn() << ", clearing" << endl;
				clear();
			}
			return;
		default:
			break;
	}

	Logger::status() << "Checking all indexed revisions... " << ::flush;

	std::string id;
	std::pair<uint32_t, uint32_t> pos;
	uint32_t crc;
	std::map<std::string, uint32_t> crcs;
	std::vector<std::string> corrupted;
	while (!(*in >> id).eof()) {
		if (!in->ok()) {
			goto corrupt;
		}

		*in >> pos.first >> pos.second;
		*in >> crc;
		if (!in->ok()) {
			goto corrupt;
		}

		index[id] = pos;
		crcs[id] = crc;

		if (cache_in == NULL || cache_index != pos.first) {
			delete cache_in;
			cache_in = new BIStream(str::printf("%s/cache.%u", path.c_str(), pos.first));
			cache_index = pos.first;
			if (!cache_in->ok()) {
				delete cache_in; cache_in = NULL;
				goto corrupt;
			}
		}
		if (cache_in != NULL) {
			if (!cache_in->seek(pos.second)) {
				goto corrupt;
			} else {
				std::vector<char> data;
				*cache_in >> data;
				if (utils::crc32(data) != crc) {
					goto corrupt;
				}
			}
		}

		PTRACE << "Revision " << id << " ok" << endl;
		continue;

corrupt:
		PTRACE << "Revision " << id << " corrupted!" << endl;
		std::cerr << "Cache: Revision " << id << " is corrupted, removing from index file" << std::endl;
		corrupted.push_back(id);
	}
	delete cache_in;
	delete in;

	Logger::status() << "done" << endl;

	Logger::info() << "Cache: Checked " << index.size() << " revisions in " << watch.elapsedMSecs() << " ms" << endl;

	if (corrupted.empty()) {
		Logger::info() << "Cache: Everything's alright" << endl;
		return;
	}

	Logger::info() << "Cache: " << corrupted.size() << " corrupted revisions, rewriting index file" << endl;

	// Remove corrupted revisions from index file
	for (unsigned int i = 0; i < corrupted.size(); i++) {
		std::map<std::string, std::pair<uint32_t, uint32_t> >::iterator it = index.find(corrupted[i]);
		if (it != index.end()) {
			index.erase(it);
		}
	}

	// Defer any signals while writing to the cache
	{
		SIGBLOCK_DEFER();

		// Rewrite index file
		GZOStream out(path+"/index");
		out << CACHE_VERSION;
		for (std::map<std::string, std::pair<uint32_t, uint32_t> >::iterator it = index.begin(); it != index.end(); ++it) {
			out << it->first;
			out << it->second.first << it->second.second;
			out << crcs[it->first];
		}
	}
}
Esempio n. 16
0
template <class T>void SafeRelease(T **ppT)
{
  if (*ppT) {
    (*ppT)->Release();
    *ppT = nullptr;
  }
}

template <class T> HRESULT SetInterface(T **ppT, IUnknown *punk)
{
  SafeRelease(ppT);
  return punk ? punk->QueryInterface(ppT) : E_NOINTERFACE;
}

class __declspec(uuid("5100FEC1-212B-4BF5-9BF8-3E650FD794A3"))
  CExecuteCommandVerb : public IExecuteCommand,
                        public IObjectWithSelection,
                        public IInitializeCommand,
                        public IObjectWithSite,
                        public IExecuteCommandApplicationHostEnvironment
{
public:

  CExecuteCommandVerb() :
    mRef(0),
    mShellItemArray(nullptr),
    mUnkSite(nullptr),
    mTargetIsFileSystemLink(false),
    mTargetIsDefaultBrowser(false),
    mTargetIsBrowser(false),
Esempio n. 17
0
int set_head(QStringList command) {
    qDebug() << "set_head(" << command.join(" ") << ")" << endl;

    /**
     * Debug
     */
    for(int i=0;i<command.size();i++) {
        qDebug() << "command.at(" << i << ")" << command.at(i) << endl;
    }

    /**
     * Check input
     */
    QTextStream errorStream(stderr);

    if(command.size() != 5) {

        errorStream << "Error: set_head(" << command.join(" ") << "): No valid number of arguments!" << endl;
        man("usage set_head");
        return 1;
    }


    if(command.at(0)!="set_head") {

        errorStream << "Error: set_head(" << command.join(" ") << "): No valid command!" << endl;
        man("usage set_head");
        return 1;
    }

    if(! command.at(2).contains(QRegExp("^(binary|integer|hex|cip)$"))) {

        errorStream << "Error: set_head(" << command.join(" ") << "): No valid CIP omode!" << endl;
        man("usage set_head");
        return 1;
    }

    if(! command.at(3).contains(QRegExp("^(request|profile|version|channel|uuid|ip|port|time|type|size|data)$"))) {

        errorStream << "Error: set_head(" << command.join(" ") << "): No valid header key!" << endl;
        man("usage set_head");
        return 1;
    }

    /**
     * Check value for integer and single value
     */
    if(command.at(2)=="integer" && command.at(3).contains(QRegExp("^(request|profile|version|channel|type|size)$"))
            && // not uint8 (0-255)
            ((! command.at(4).contains(QRegExp("^\\d\\d?\\d?$")))
            || command.at(4).toInt() < 0
            || command.at(4).toInt() > 255)) {

        errorStream << "Error: set_head(" << command.join(" ") << "): No valid header value!" << endl;
        man("usage set_head");
        return 1;
    }

    /**
     * Check value for binary and single value
     */
    if(command.at(2)=="binary" && command.at(3).contains(QRegExp("^(request|profile|version|channel|type|size)$"))
            && // not uint8 (00000000-11111111)
            ((! command.at(4).contains(QRegExp("^(0|1){8}$"))))) {

        errorStream << "Error: set_head(" << command.join(" ") << "): No valid header value!" << endl;
        man("usage set_head");
        return 1;
    }

    /**
     * Check value for hex and single value
     */
    if(command.at(2)=="hex" && command.at(3).contains(QRegExp("^(request|profile|version|channel|type|size)$"))
            && // not uint8 (00-ff)
            ((! command.at(4).contains(QRegExp("^(\\d|a|b|c|d|e|f){2}$"))))) {

        errorStream << "Error: set_head(" << command.join(" ") << "): No valid header value!" << endl;
        man("usage set_head");
        return 1;
    }


    /**
     * Check value for binary and uuid
     */
    if(command.at(2)=="binary" && command.at(3)=="uuid") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for integer and uuid
     */
    if(command.at(2)=="integer" && command.at(3)=="uuid") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for hex and uuid
     */
    if(command.at(2)=="hex" && command.at(3)=="uuid"
            && // not (0-16^32)
            ((! command.at(4).contains(QRegExp("^(\\d|a|b|c|d|e|f){32}$"))))) {

        errorStream << "Error: set_head(" << command.join(" ") << "): No valid header value!" << endl;
        man("usage set_head");
        return 1;
    }

    /**
     * Check value for cip and uuid
     */
    if(command.at(2)=="cip" && command.at(3)=="uuid") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }


    /**
     * Check value for binary and ip
     */
    if(command.at(2)=="binary" && command.at(3)=="ip") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for integer and ip
     */
    if(command.at(2)=="integer" && command.at(3)=="ip") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for hex and ip
     */
    if(command.at(2)=="hex" && command.at(3)=="ip") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for cip and ip
     */
    if(command.at(2)=="cip" && command.at(3)=="ip") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }




    /**
     * Check value for binary and port
     */
    if(command.at(2)=="binary" && command.at(3)=="port") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for integer and port
     */
    if(command.at(2)=="integer" && command.at(3)=="port") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for hex and port
     */
    if(command.at(2)=="hex" && command.at(3)=="port") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for cip and port
     */
    if(command.at(2)=="cip" && command.at(3)=="port") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }




    /**
     * Check value for binary and time
     */
    if(command.at(2)=="binary" && command.at(3)=="time") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for integer and time
     */
    if(command.at(2)=="integer" && command.at(3)=="time") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for hex and time
     */
    if(command.at(2)=="hex" && command.at(3)=="time") {
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * Check value for cip and time
     */
    if(command.at(2)=="cip" && command.at(3)=="time" && command.at(4)!="now") {
        errorStream << "Error: set_head(" << command.join(" ") << "): No valid header value!" << endl;
        man("usage set_head time");
        return 1;
    }



    /**
     * Read file
     */

    QString filePath;

    filePath = CIP_ROOT;
    filePath += "/" + command.at(1);

    qDebug() << "filePath: " << filePath << endl;

    QFile file(filePath);
    if (!file.open(QIODevice::ReadOnly)) {

        errorStream << "Error: set_head(" << command.join(" ") << ") can not read " << filePath << endl;
        return 1;
    }

    QByteArray byteArray;
    byteArray = file.readAll();
    file.close();

    qDebug() << "byteArray.size(): " << byteArray.size() << endl;



    /**
     * Define map with start position
     */

    QMap<QString, int> keys;
    int pos;

    keys["request"] = 0;
    keys["profile"] = 1;
    keys["version"] = 2;
    keys["channel"] = 3;
    keys["uuid"] = 4;
    keys["ip"] = 20;
    keys["port"] = 24;
    keys["time"] = 26;
    keys["type"] = 34;
    keys["size"] = 35;



    QByteArray value;
    bool ok;


    /**
     * One byte keys (without size)
     */

    if(command.at(3).contains(QRegExp("^(request|profile|version|channel|type|size)$"))) {


        if (keys.contains(command.at(3))) {
            qDebug() << "keys.contains(" << command.at(3) << ")" << endl;

            if(command.at(2)=="binary") {
                value.append(command.at(4).toUInt(&ok, 2));

                if(!ok) {
                    errorStream << "Cannot convert "<< command.at(4) << " to base 2!" << endl;
                    return 1;
                }
            }

            if(command.at(2)=="integer") {
                value.append(command.at(4).toUInt(&ok, 10));

                if(!ok) {
                    errorStream << "Cannot convert "<< command.at(4) << " to base 10!" << endl;
                    return 1;
                }
            }

            if(command.at(2)=="hex") {
                value.append(command.at(4).toUInt(&ok, 16));

                if(!ok) {
                    errorStream << "Cannot convert "<< command.at(4) << " to base 16!" << endl;
                    return 1;
                }
            }

            if(command.at(2)=="cip") {
                errorStream << "Not yet specified!" << endl;
                return 1;
            }

            pos = keys[command.at(3)];

            qDebug() << "byteArray.replace(" << pos << ", 1, " << value << ")" << endl;
            byteArray.replace(pos, 1, value);
        }
        else {
            errorStream << "Cannot find key for "<< command.at(3) << "!" << endl;
            return 1;
        }

    }

    /**
     * uuid (16)
     */
    if(command.at(3)=="uuid") {
        if (keys.contains(command.at(3))) {
            qDebug() << "keys.contains(" << command.at(3) << ")" << endl;


            value.append(command.at(4).toLatin1());
            value.insert(20, '-');
            value.insert(16, '-');
            value.insert(12, '-');
            value.insert(8, '-');

            qDebug() << "value: " << value << endl;

            QUuid uuid(value);

            pos = keys[command.at(3)];

            qDebug() << "byteArray.replace(" << pos << ", 16, " << uuid << ")" << endl;
            byteArray.replace(pos, 16, uuid.toRfc4122());

        }
        else {
            errorStream << "Cannot find key for "<< command.at(3) << "!" << endl;
            return 1;
        }
    }

    /**
     * ip (4)
     */
    if(command.at(3)=="ip") {
        if (keys.contains(command.at(3))) {
            qDebug() << "keys.contains(" << command.at(3) << ")" << endl;
        }
        else {
            errorStream << "Cannot find key for "<< command.at(3) << "!" << endl;
            return 1;
        }
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * port (2)
     */
    if(command.at(3)=="port") {
        if (keys.contains(command.at(3))) {
            qDebug() << "keys.contains(" << command.at(3) << ")" << endl;
        }
        else {
            errorStream << "Cannot find key for "<< command.at(3) << "!" << endl;
            return 1;
        }
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }

    /**
     * time (8)
     */
    if(command.at(3)=="time") {
        if (keys.contains(command.at(3))) {
            qDebug() << "keys.contains(" << command.at(3) << ")" << endl;
        }
        else {
            errorStream << "Cannot find key for "<< command.at(3) << "!" << endl;
            return 1;
        }

        uint unixTime = QDateTime::currentDateTime().toTime_t();
        qDebug().noquote().nospace() << "NOW: " << QDateTime::fromTime_t(unixTime).toString() << endl;

        pos = keys[command.at(3)];

        for(int j = 0; j < 8; j++) {

            byteArray[pos++] = unixTime%256;
            qDebug().noquote().nospace() << "time[" << j << "]: " << QString("%1").arg(unixTime%256, 8, 2, QLatin1Char('0'));

            unixTime = unixTime >> 8;
        }
    }

    /**
     * size (1)
     */
    if(command.at(3)=="size") {
        if (keys.contains(command.at(3))) {
            qDebug() << "keys.contains(" << command.at(3) << ")" << endl;
        }
        else {
            errorStream << "Cannot find key for "<< command.at(3) << "!" << endl;
            return 1;
        }

        pos = keys[command.at(3)];

        qDebug() << "byteArray.replace(" << pos << ", 1, " << value << ")" << endl;
        byteArray.replace(pos, 1, value);
    }

    /**
     * data (size)
     */
    if(command.at(3)=="data") {
        if (keys.contains(command.at(3))) {
            qDebug() << "keys.contains(" << command.at(3) << ")" << endl;
        }
        else {
            errorStream << "Cannot find key for "<< command.at(3) << "!" << endl;
            return 1;
        }
        errorStream << "Not yet implemented!" << endl;
        return 1;
    }


    /**
     * Write file
     */

    if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {

        errorStream << "Error: set_head(" << command.join(" ") << ") can not write to file " << filePath << endl;
        return 1;
    }
    file.write(byteArray);

    file.close();

    qDebug() << "filePath: " << filePath << endl;

    return 0;
}
Esempio n. 18
0
**
**    Magnus Norddahl
*/

#include "Sound/precomp.h"
#include "soundoutput_win32.h"
#include "API/Core/System/exception.h"
#include "API/Core/Text/logger.h"
#include "Core/System/Win32/system_win32.h"
#include <mmreg.h>
#include "API/Core/Math/cl_math.h"

// KSDATAFORMAT_SUBTYPE_IEEE_FLOAT is not available on some old headers
#ifndef KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
#ifdef _MSC_VER
struct __declspec(uuid("00000003-0000-0010-8000-00aa00389b71")) KSDATAFORMAT_SUBTYPE_IEEE_FLOAT_STRUCT;
#define KSDATAFORMAT_SUBTYPE_IEEE_FLOAT __uuidof(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT_STRUCT)
#else
#include <initguid.h>
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT,0x00000003L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
DEFINE_GUID(GUID_NULL,0x00000000L, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
#endif
#endif

namespace clan
{
	SoundOutput_Win32::SoundOutput_Win32(int init_mixing_frequency, int init_mixing_latency)
		: SoundOutput_Impl(init_mixing_frequency, init_mixing_latency), audio_buffer_ready_event(INVALID_HANDLE_VALUE), is_playing(false), fragment_size(0), wait_timeout(mixing_latency * 2), write_pos(0)
	{
		try
		{
Esempio n. 19
0
void
MediaEngineWebRTC::EnumerateVideoDevices(nsTArray<nsRefPtr<MediaEngineVideoSource> >* aVSources)
{
#ifdef MOZ_B2G_CAMERA
  MutexAutoLock lock(mMutex);

  /**
   * We still enumerate every time, in case a new device was plugged in since
   * the last call. TODO: Verify that WebRTC actually does deal with hotplugging
   * new devices (with or without new engine creation) and accordingly adjust.
   * Enumeration is not neccessary if GIPS reports the same set of devices
   * for a given instance of the engine. Likewise, if a device was plugged out,
   * mVideoSources must be updated.
   */
  int num = 0;
  nsresult result;
  result = ICameraControl::GetNumberOfCameras(num);
  if (num <= 0 || result != NS_OK) {
    return;
  }

  for (int i = 0; i < num; i++) {
    nsCString cameraName;
    result = ICameraControl::GetCameraName(i, cameraName);
    if (result != NS_OK) {
      continue;
    }

    nsRefPtr<MediaEngineWebRTCVideoSource> vSource;
    NS_ConvertUTF8toUTF16 uuid(cameraName);
    if (mVideoSources.Get(uuid, getter_AddRefs(vSource))) {
      // We've already seen this device, just append.
      aVSources->AppendElement(vSource.get());
    } else {
      vSource = new MediaEngineWebRTCVideoSource(i);
      mVideoSources.Put(uuid, vSource); // Hashtable takes ownership.
      aVSources->AppendElement(vSource);
    }
  }

  return;
#else
  ScopedCustomReleasePtr<webrtc::ViEBase> ptrViEBase;
  ScopedCustomReleasePtr<webrtc::ViECapture> ptrViECapture;

  // We spawn threads to handle gUM runnables, so we must protect the member vars
  MutexAutoLock lock(mMutex);

#ifdef MOZ_WIDGET_ANDROID
  jobject context = mozilla::AndroidBridge::Bridge()->GetGlobalContextRef();

  // get the JVM
  JavaVM *jvm = mozilla::AndroidBridge::Bridge()->GetVM();

  if (webrtc::VideoEngine::SetAndroidObjects(jvm, (void*)context) != 0) {
    LOG(("VieCapture:SetAndroidObjects Failed"));
    return;
  }
#endif
  if (!mVideoEngine) {
    if (!(mVideoEngine = webrtc::VideoEngine::Create())) {
      return;
    }
  }

  PRLogModuleInfo *logs = GetWebRTCLogInfo();
  if (!gWebrtcTraceLoggingOn && logs && logs->level > 0) {
    // no need to a critical section or lock here
    gWebrtcTraceLoggingOn = 1;

    const char *file = PR_GetEnv("WEBRTC_TRACE_FILE");
    if (!file) {
      file = "WebRTC.log";
    }

    LOG(("%s Logging webrtc to %s level %d", __FUNCTION__, file, logs->level));

    mVideoEngine->SetTraceFilter(logs->level);
    mVideoEngine->SetTraceFile(file);
  }

  ptrViEBase = webrtc::ViEBase::GetInterface(mVideoEngine);
  if (!ptrViEBase) {
    return;
  }

  if (!mVideoEngineInit) {
    if (ptrViEBase->Init() < 0) {
      return;
    }
    mVideoEngineInit = true;
  }

  ptrViECapture = webrtc::ViECapture::GetInterface(mVideoEngine);
  if (!ptrViECapture) {
    return;
  }

  /**
   * We still enumerate every time, in case a new device was plugged in since
   * the last call. TODO: Verify that WebRTC actually does deal with hotplugging
   * new devices (with or without new engine creation) and accordingly adjust.
   * Enumeration is not neccessary if GIPS reports the same set of devices
   * for a given instance of the engine. Likewise, if a device was plugged out,
   * mVideoSources must be updated.
   */
  int num = ptrViECapture->NumberOfCaptureDevices();
  if (num <= 0) {
    return;
  }

  for (int i = 0; i < num; i++) {
    const unsigned int kMaxDeviceNameLength = 128; // XXX FIX!
    const unsigned int kMaxUniqueIdLength = 256;
    char deviceName[kMaxDeviceNameLength];
    char uniqueId[kMaxUniqueIdLength];

    // paranoia
    deviceName[0] = '\0';
    uniqueId[0] = '\0';
    int error = ptrViECapture->GetCaptureDevice(i, deviceName,
                                                sizeof(deviceName), uniqueId,
                                                sizeof(uniqueId));

    if (error) {
      LOG((" VieCapture:GetCaptureDevice: Failed %d",
           ptrViEBase->LastError() ));
      continue;
    }
#ifdef DEBUG
    LOG(("  Capture Device Index %d, Name %s", i, deviceName));

    webrtc::CaptureCapability cap;
    int numCaps = ptrViECapture->NumberOfCapabilities(uniqueId, kMaxUniqueIdLength);
    LOG(("Number of Capabilities %d", numCaps));
    for (int j = 0; j < numCaps; j++) {
      if (ptrViECapture->GetCaptureCapability(uniqueId, kMaxUniqueIdLength,
                                              j, cap ) != 0 ) {
        break;
      }
      LOG(("type=%d width=%d height=%d maxFPS=%d",
           cap.rawType, cap.width, cap.height, cap.maxFPS ));
    }
#endif

    if (uniqueId[0] == '\0') {
      // In case a device doesn't set uniqueId!
      strncpy(uniqueId, deviceName, sizeof(uniqueId));
      uniqueId[sizeof(uniqueId)-1] = '\0'; // strncpy isn't safe
    }

    nsRefPtr<MediaEngineWebRTCVideoSource> vSource;
    NS_ConvertUTF8toUTF16 uuid(uniqueId);
    if (mVideoSources.Get(uuid, getter_AddRefs(vSource))) {
      // We've already seen this device, just append.
      aVSources->AppendElement(vSource.get());
    } else {
      vSource = new MediaEngineWebRTCVideoSource(mVideoEngine, i);
      mVideoSources.Put(uuid, vSource); // Hashtable takes ownership.
      aVSources->AppendElement(vSource);
    }
  }

  if (mHasTabVideoSource)
    aVSources->AppendElement(new MediaEngineTabVideoSource());

  return;
#endif
}
Esempio n. 20
0
        CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
        pVSS->RemoveAll();
    } else if (IsHdmvSub(&m_mt)) {
        CAutoLock cAutoLock2(m_pSubLock);
        CRenderedHdmvSubtitle* pHdmvSubtitle = (CRenderedHdmvSubtitle*)(ISubStream*)m_pSubStream;
        pHdmvSubtitle->NewSegment(tStart, tStop, dRate);
    }

    TRACE(_T("NewSegment: InvalidateSubtitle(%I64d, ...)\n"), tStart);
    // IMPORTANT: m_pSubLock must not be locked when calling this
    InvalidateSubtitle(tStart, m_pSubStream);

    return __super::NewSegment(tStart, tStop, dRate);
}

interface __declspec(uuid("D3D92BC3-713B-451B-9122-320095D51EA5"))
IMpeg2DemultiplexerTesting :
public IUnknown {
    STDMETHOD(GetMpeg2StreamType)(ULONG * plType) PURE;
    STDMETHOD(toto)() PURE;
};

STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample)
{
    HRESULT hr;

    hr = __super::Receive(pSample);
    if (FAILED(hr)) {
        return hr;
    }
Esempio n. 21
0
/*!
 * \brief JsonDbObject::updateVersionReplicating implements a replicatedWrite
 * \param other the (remote) object to include into this one.
 * \return if the passed object was a valid replication
 */
bool JsonDbObject::updateVersionReplicating(const JsonDbObject &other)
{
    // these two will be the final _meta content
    QJsonArray history;
    QJsonArray conflicts;

    // let's go thru all version, i.e. this, this._conflicts, other, and other._conflicts
    {
        // thanks to the operator <, documents will sort and remove duplicates
        // the value is just for show, QSet is based on QHash, which does not sort
        QMap<JsonDbObject,bool> documents;

        QUuid id;
        if (!isEmpty()) {
            id = uuid();
            populateMerge(&documents, id, *this);
        } else {
            id = other.uuid();
        }
        if (!populateMerge(&documents, id, other, true))
            return false;

        // now we have all versions sorted and duplicates removed
        // let's figure out what to keep, what to toss
        // this is O(n^2) but should be fine in real world situations
        for (QMap<JsonDbObject,bool>::const_iterator ii = documents.begin(); ii != documents.end(); ii++) {
            bool alive = !ii.key().isDeleted();
            for (QMap<JsonDbObject,bool>::const_iterator jj = ii + 1; alive && jj != documents.end(); jj++)
                if (ii.key().isAncestorOf(jj.key()))
                    alive = false;

            if (ii+1 == documents.end()) {
                // last element, so found the winner,
                // assigning to *this, which is head
                *this = ii.key();
                populateHistory(&history, *this, false);
            } else if (alive) {
                // this is a conflict, strip _meta and keep it
                JsonDbObject conflict(ii.key());
                conflict.remove(JsonDbString::kMetaStr);
                conflicts.append(conflict);
            } else {
                // this version was replaced, just keep history
                populateHistory(&history, ii.key(), true);
            }
        }
    }

    // let's write a new _meta into head
    if (history.size() || conflicts.size()) {
        QJsonObject meta;
        if (history.size())
            meta.insert(QStringLiteral("history"), history);
        if (conflicts.size())
            meta.insert(JsonDbString::kConflictsStr, conflicts);
        insert(JsonDbString::kMetaStr, meta);
    } else {
        // this is really just for sanity reason, but it feels better to have it
        // aka: this branch should never be reached in real world situations
        remove(JsonDbString::kMetaStr);
    }

    return true;
}
Esempio n. 22
0
 double DiscreteVariable_Impl::getValue(const DataPoint& dataPoint) const {
   OptionalInt index = dataPoint.problem().getVariableIndexByUUID(uuid());
   OS_ASSERT(index);
   return dataPoint.variableValues()[*index].toDouble();
 }
Esempio n. 23
0
File: main.cpp Progetto: jmfb/Com
#define _CRT_SECURE_NO_WARNINGS
#include "Com.h"

struct __declspec(uuid("4DE37185-5855-4B6F-A0D8-F4B530548510")) IFoo : public IDispatch
{
	virtual HRESULT __stdcall Bar() = 0;
};

struct __declspec(uuid("4DE37185-5855-4B6F-A0D8-F4B530548511")) IFoo2 : public IDispatch
{
	virtual HRESULT __stdcall Bar2() = 0;
};

template <typename Interface>
class IFooPtrT : public Com::Pointer<Interface>
{
public:
	IFooPtrT(Interface* value = nullptr)
		: Com::Pointer<Interface>(value)
	{
	}
	IFooPtrT<Interface>& operator=(Interface* value)
	{
		using Base = Com::Pointer<Interface>;
		Base::operator=(value);
		return *this;
	}
	operator Interface*() const
	{
		return p;
	}
Esempio n. 24
0
static wxString GetIidName(REFIID riid)
{
  // an association between symbolic name and numeric value of an IID
  struct KNOWN_IID {
    const IID  *pIid;
    const wxChar *szName;
  };

  // construct the table containing all known interfaces
  #define ADD_KNOWN_IID(name) { &IID_I##name, _T(#name) }

  static const KNOWN_IID aKnownIids[] = {
    ADD_KNOWN_IID(AdviseSink),
    ADD_KNOWN_IID(AdviseSink2),
    ADD_KNOWN_IID(BindCtx),
    ADD_KNOWN_IID(ClassFactory),
#if ( !defined( __VISUALC__) || (__VISUALC__!=1010) ) && !defined(__MWERKS__)
    ADD_KNOWN_IID(ContinueCallback),
    ADD_KNOWN_IID(EnumOleDocumentViews),
    ADD_KNOWN_IID(OleCommandTarget),
    ADD_KNOWN_IID(OleDocument),
    ADD_KNOWN_IID(OleDocumentSite),
    ADD_KNOWN_IID(OleDocumentView),
    ADD_KNOWN_IID(Print),
#endif
    ADD_KNOWN_IID(DataAdviseHolder),
    ADD_KNOWN_IID(DataObject),
    ADD_KNOWN_IID(Debug),
    ADD_KNOWN_IID(DebugStream),
    ADD_KNOWN_IID(DfReserved1),
    ADD_KNOWN_IID(DfReserved2),
    ADD_KNOWN_IID(DfReserved3),
    ADD_KNOWN_IID(Dispatch),
    ADD_KNOWN_IID(DropSource),
    ADD_KNOWN_IID(DropTarget),
    ADD_KNOWN_IID(EnumCallback),
    ADD_KNOWN_IID(EnumFORMATETC),
    ADD_KNOWN_IID(EnumGeneric),
    ADD_KNOWN_IID(EnumHolder),
    ADD_KNOWN_IID(EnumMoniker),
    ADD_KNOWN_IID(EnumOLEVERB),
    ADD_KNOWN_IID(EnumSTATDATA),
    ADD_KNOWN_IID(EnumSTATSTG),
    ADD_KNOWN_IID(EnumString),
    ADD_KNOWN_IID(EnumUnknown),
    ADD_KNOWN_IID(EnumVARIANT),
    ADD_KNOWN_IID(ExternalConnection),
    ADD_KNOWN_IID(InternalMoniker),
    ADD_KNOWN_IID(LockBytes),
    ADD_KNOWN_IID(Malloc),
    ADD_KNOWN_IID(Marshal),
    ADD_KNOWN_IID(MessageFilter),
    ADD_KNOWN_IID(Moniker),
    ADD_KNOWN_IID(OleAdviseHolder),
    ADD_KNOWN_IID(OleCache),
    ADD_KNOWN_IID(OleCache2),
    ADD_KNOWN_IID(OleCacheControl),
    ADD_KNOWN_IID(OleClientSite),
    ADD_KNOWN_IID(OleContainer),
    ADD_KNOWN_IID(OleInPlaceActiveObject),
    ADD_KNOWN_IID(OleInPlaceFrame),
    ADD_KNOWN_IID(OleInPlaceObject),
    ADD_KNOWN_IID(OleInPlaceSite),
    ADD_KNOWN_IID(OleInPlaceUIWindow),
    ADD_KNOWN_IID(OleItemContainer),
    ADD_KNOWN_IID(OleLink),
    ADD_KNOWN_IID(OleManager),
    ADD_KNOWN_IID(OleObject),
    ADD_KNOWN_IID(OlePresObj),
    ADD_KNOWN_IID(OleWindow),
    ADD_KNOWN_IID(PSFactory),
    ADD_KNOWN_IID(ParseDisplayName),
    ADD_KNOWN_IID(Persist),
    ADD_KNOWN_IID(PersistFile),
    ADD_KNOWN_IID(PersistStorage),
    ADD_KNOWN_IID(PersistStream),
    ADD_KNOWN_IID(ProxyManager),
    ADD_KNOWN_IID(RootStorage),
    ADD_KNOWN_IID(RpcChannel),
    ADD_KNOWN_IID(RpcProxy),
    ADD_KNOWN_IID(RpcStub),
    ADD_KNOWN_IID(RunnableObject),
    ADD_KNOWN_IID(RunningObjectTable),
    ADD_KNOWN_IID(StdMarshalInfo),
    ADD_KNOWN_IID(Storage),
    ADD_KNOWN_IID(Stream),
    ADD_KNOWN_IID(StubManager),
    ADD_KNOWN_IID(Unknown),
    ADD_KNOWN_IID(ViewObject),
    ADD_KNOWN_IID(ViewObject2),
  };

  // don't clobber preprocessor name space
  #undef ADD_KNOWN_IID

  // try to find the interface in the table
  for ( size_t ui = 0; ui < WXSIZEOF(aKnownIids); ui++ ) {
    if ( riid == *aKnownIids[ui].pIid ) {
      return aKnownIids[ui].szName;
    }
  }

#ifndef __WXWINCE__
  // unknown IID, just transform to string
  Uuid uuid(riid);
  return wxString((const wxChar *)uuid);
#else
  return wxEmptyString;
#endif
}
Esempio n. 25
0
 bool AnalysisObject_Impl::uuidEqual(const AnalysisObject& other) const {
   return (uuid() == other.uuid());
 }
Esempio n. 26
0
//
//	HideDesktop()		- hides the desktop
//	RestoreDesktop()	- restore the desktop
//

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <WinInet.h> // Shell object uses INTERNET_MAX_URL_LENGTH (go figure)
#if _MSC_VER < 1400
#define _WIN32_IE 0x0400
#endif
#include <atlbase.h> // ATL smart pointers
#include <shlguid.h> // shell GUIDs
#include <shlobj.h>  // IActiveDesktop

struct __declspec(uuid("F490EB00-1240-11D1-9888-006097DEACF9")) IActiveDesktop;

#define PACKVERSION(major,minor) MAKELONG(minor,major)

DWORD GetDllVersion(LPCTSTR lpszDllName)
{
    HINSTANCE hinstDll;
    DWORD dwVersion = 0;

    hinstDll = LoadLibrary(lpszDllName);
	
    if(hinstDll)
    {
        DLLGETVERSIONPROC pDllGetVersion;

        pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
Esempio n. 27
0
int CmdDuplicate::execute (std::string&)
{
  int rc = 0;
  int count = 0;

  // Apply filter.
  Filter filter;
  std::vector <Task> filtered;
  filter.subset (filtered);
  if (filtered.size () == 0)
  {
    context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
    return 1;
  }

  // Accumulated project change notifications.
  std::map <std::string, std::string> projectChanges;

  for (auto& task : filtered)
  {
    // Duplicate the specified task.
    Task dup (task);
    dup.id = 0;                    // Reset, and TDB2::add will set.
    dup.set ("uuid", uuid ());     // Needs a new UUID.
    dup.remove ("start");          // Does not inherit start date.
    dup.remove ("end");            // Does not inherit end date.
    dup.remove ("entry");          // Does not inherit entry date.

    // When duplicating a child task, downgrade it to a plain task.
    if (dup.has ("parent"))
    {
      dup.remove ("parent");
      dup.remove ("recur");
      dup.remove ("until");
      dup.remove ("imask");
      std::cout << format (STRING_CMD_DUPLICATE_NON_REC, task.id)
          << "\n";
    }

    // When duplicating a parent task, create a new parent task.
    else if (dup.getStatus () == Task::recurring)
    {
      dup.remove ("mask");
      std::cout << format (STRING_CMD_DUPLICATE_REC, task.id)
          << "\n";
    }

    dup.setStatus (Task::pending); // Does not inherit status.
                                   // Must occur after Task::recurring check.

    dup.modify (Task::modAnnotate);

    if (permission (format (STRING_CMD_DUPLICATE_CONFIRM,
                            task.id,
                            task.get ("description")),
                    filtered.size ()))
    {
      context.tdb2.add (dup);
      ++count;
      feedback_affected (STRING_CMD_DUPLICATE_TASK, task);

      if (context.verbose ("new-id"))
        std::cout << format (STRING_CMD_ADD_FEEDBACK, dup.id) + "\n";
      else if (context.verbose ("new-uuid"))
        std::cout << format (STRING_CMD_ADD_FEEDBACK, dup.get ("uuid")) + "\n";

      if (context.verbose ("project"))
        projectChanges[task.get ("project")] = onProjectChange (task);
    }
    else
    {
      std::cout << STRING_CMD_DUPLICATE_NO << "\n";
      rc = 1;
      if (_permission_quit)
        break;
    }
  }

  // Now list the project changes.
  for (auto& change : projectChanges)
    if (change.first != "")
      context.footnote (change.second);

  feedback_affected (count == 1 ? STRING_CMD_DUPLICATE_1 : STRING_CMD_DUPLICATE_N, count);
  return rc;
}
Esempio n. 28
0
CStreamSwitcherInputPin::CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr, LPCWSTR pName)
    : CBaseInputPin(NAME("CStreamSwitcherInputPin"), pFilter, &pFilter->m_csState, phr, pName)
	, m_Allocator(this, phr)
	, m_bSampleSkipped(FALSE)
	, m_bQualityChanged(FALSE)
	, m_bUsingOwnAllocator(FALSE)
	, m_evBlock(TRUE)
	, m_fCanBlock(false)
	, m_hNotifyEvent(NULL)
{
	m_bCanReconnectWhenActive = TRUE;
}


class __declspec(uuid("138130AF-A79B-45D5-B4AA-87697457BA87")) NeroAudioDecoder {};

STDMETHODIMP CStreamSwitcherInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
	return
		QI(IStreamSwitcherInputPin)
		IsConnected() && GetCLSID(GetFilterFromPin(GetConnected())) == __uuidof(NeroAudioDecoder) && QI(IPinConnection)
		__super::NonDelegatingQueryInterface(riid, ppv);
}

// IPinConnection

STDMETHODIMP CStreamSwitcherInputPin::DynamicQueryAccept(const AM_MEDIA_TYPE* pmt)
{
	return QueryAccept(pmt);
}
void
DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
{
    TomahawkSqlQuery query = dbi->newquery();
    QList<Tomahawk::query_ptr> ql;

    QString whereToken;
    if ( !source().isNull() )
    {
        whereToken = QString( "WHERE source %1" ).arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) );
    }

    QString sql = QString(
            "SELECT track, playtime, secs_played "
            "FROM playback_log "
            "%1 "
            "ORDER BY playtime DESC "
            "%2" ).arg( whereToken )
                  .arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );

    query.prepare( sql );
    query.exec();

    while( query.next() )
    {
        TomahawkSqlQuery query_track = dbi->newquery();

        QString sql = QString(
                "SELECT track.name, artist.name "
                "FROM track, artist "
                "WHERE artist.id = track.artist "
                "AND track.id = %1"
                ).arg( query.value( 0 ).toUInt() );

        query_track.prepare( sql );
        query_track.exec();

        if ( query_track.next() )
        {
            Tomahawk::query_ptr q = Tomahawk::Query::get( query_track.value( 1 ).toString(), query_track.value( 0 ).toString(), QString(), uuid() );
            ql << q;
        }
    }

    qDebug() << Q_FUNC_INFO << ql.length();

    if ( ql.count() )
        emit tracks( ql );
}
Esempio n. 30
0
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "stdafx.h"
#include <numeric>
#include <sstream>
#include <unordered_map>
#include <evntrace.h>
#include <evntcons.h>
#include <tdh.h>

#include "EtwCommon.h"

#pragma comment(lib, "tdh.lib")

struct __declspec(uuid("{83ed54f0-4d48-4e45-b16e-726ffd1fa4af}")) Microsoft_Windows_Networking_Correlation;
struct __declspec(uuid("{2ed6006e-4729-4609-b423-3ee7bcd678ef}")) Microsoft_Windows_NDIS_PacketCapture;

/*
per->EventDescriptor.Keyword

0x80000601'40000001 PacketStart
0x80000601'80000001 PacketEnd
0x00000001'00000000 SendPath
0x00000200'00000000 PiiPresent
0x00000400'00000000 Packet
*/

constexpr ULONGLONG KeywordPacketStart = 0x00000000'40000000;
constexpr ULONGLONG KeywordPacketEnd = 0x00000000'80000000;