void visual_system_impl::init_eye()
{
	// no eye is selected if camera name is incorrect to show problem visually!!!
	// please don't change selection logic
#if 0
	eye_ = (!props_.channel.camera_name.empty()) 
		? find_object<visual_control_ptr>(this, props_.channel.camera_name)
		: find_first_object<visual_control_ptr>(this) ;

	if (!eye_ && !props_.channel.camera_name.empty())
		LogWarn("Can't find camera: " << props_.channel.camera_name);

#else
	eye_ = find_object<visual_control_ptr>(this, props_.channel.camera_name);

	if (!eye_ && !props_.channel.camera_name.empty())
		LogWarn("Can't find camera: " << props_.channel.camera_name);

	if(!eye_)
		eye_ = find_first_object<visual_control_ptr>(this) ;
#endif


#if 0
	viewport_->SetClarityScale(props_.channel.pixel_scale);
	viewport_->set_geom_corr(props_.channel.cylindric_geom_corr ? victory::IViewport::explicit_cylinder : victory::IViewport::no_geom_corr);

	init_frustum_projection();
#endif

	update_eye();

}
Exemplo n.º 2
0
void *Thread::ThreadRun(void *myThread)
{
	Thread *thread = reinterpret_cast<Thread*>(myThread);
	thread->mRunning = true;
	
#ifdef PTW32_STATIC_LIB
	pthread_win32_thread_attach_np();
#endif
	
	try {
		thread->mTask->run();
	}
	catch(const std::exception &e)
	{
		LogWarn("Thread::ThreadRun", String("Unhandled exception in thread: ") + e.what()); 
	}
	catch(...)
	{
		LogWarn("Thread::ThreadRun", String("Unhandled unknown exception in thread")); 
	}
	
	thread->mRunning = false;
	if(thread->mAutoDelete) delete thread;
	
#ifdef PTW32_STATIC_LIB
	pthread_win32_thread_detach_np();
#endif
	pthread_exit(NULL);
	return NULL;
}
Exemplo n.º 3
0
int setup_server_sockets(struct srv_sock_info ssi[])
{
	int i=0;

	ssi[0].sd = ssi[1].sd = -1;
	// Only enqueue sockets successfully bound or that weren't disabled.
	if (tcsd_options.disable_ipv4) {
		LogWarn("IPv4 support disabled by configuration option");
	} else {
		if (setup_ipv4_socket(&ssi[i]) == 0)
			i++;
	}

	if (tcsd_options.disable_ipv6) {
		LogWarn("IPv6 support disabled by configuration option");
	} else {
		setup_ipv6_socket(&ssi[i]);
	}

	// It's only a failure if both sockets are unavailable.
	if ((ssi[0].sd == -1) && (ssi[1].sd == -1)) {
		return -1;
	}

	return 0;
}
Exemplo n.º 4
0
void ImageExport::processExport(){
    exportQueued_ = false;
    auto image = imagePort_.getData();

    if (image && !imageFile_.get().empty()) {
        const Layer* layer = image->getColorLayer();
        if (layer){
            std::string fileExtension = filesystem::getFileExtension(imageFile_.get());
            auto writer = 
                DataWriterFactory::getPtr()->getWriterForTypeAndExtension<Layer>(fileExtension);

            if (writer) {
                try {
                    writer->setOverwrite(overwrite_.get());
                    writer->writeData(layer, imageFile_.get());
                    LogInfo("Image color layer exported to disk: " << imageFile_.get());
                } catch (DataWriterException const& e) {
                    util::log(e.getContext(), e.getMessage(), LogLevel::Error);
                }
            } else {
                LogError("Error: Could not find a writer for the specified extension and data type");
            }
        }
        else {
            LogError("Error: Could not find color layer to write out");
        }
    } else if (imageFile_.get().empty()) {
        LogWarn("Error: Please specify a file to write to");
    } else if (!image) {
        LogWarn("Error: Please connect an image to export");
    }
}
Exemplo n.º 5
0
bool AudioDevice::createMainContext()
{
	LogInfo("Creating OpenAL main context");

	// Create a main context.
	mainContext = createContext();
	mainContext->makeCurrent();

	const ALchar* version = alGetString(AL_VERSION);
	
	if( !version )
	{
		LogWarn("Could not get OpenAL version");
		return false;
	}
	
	LogInfo("Using OpenAL version %s", version);

	if( AudioCheckError() )
	{
		LogWarn("Error initializing OpenAL: %s", AudioGetError());
		return false;
	}

	return true;
}
Exemplo n.º 6
0
bool VidscaleSHMIntf::removeRabRecordInSharedMemory(umtsRab *pRabObject)
{
    bool retVal = true;

    LogDebug("removeTunnelInSharedMemory\n");
    if(!(deleteSHMHashEntry((char*)(&(pRabObject->upTeidKey)), SHM_KEY_TUN, pRabObject->imsi)))
    {
      LogWarn("UPTEID - Old Session deletion failed \n");
      retVal = false;
    }
    else
    {
      LogInfo("UPTEID - delete entry successful\n");
    }

    if(!(deleteSHMHashEntry((char*)(&(pRabObject->downTeidKey)), SHM_KEY_TUN, pRabObject->imsi)))
    {
      LogWarn("DOWN TEID -Old Session deletion failed \n");
      retVal = false;
    }
    else
    {
      LogInfo("DOWNTEID - delete entry successful\n");
    }

    phashValueFreeMemMgrObj->pushFreeMem(pRabObject , (pRabObject->imsi%MAX_CONTROLLING_ENTITIES)); 
    return retVal;
}
Exemplo n.º 7
0
void VolumeExport::exportVolume() {
    auto volume = volumePort_.getData();

    if (volume && !volumeFile_.get().empty()) {
        std::string fileExtension = filesystem::getFileExtension(volumeFile_.get());
        auto writer =
            DataWriterFactory::getPtr()->getWriterForTypeAndExtension<Volume>(fileExtension);

        if (writer) {
            try {
                writer->setOverwrite(overwrite_.get());
                writer->writeData(volume.get(), volumeFile_.get());
                LogInfo("Volume exported to disk: " << volumeFile_.get());
            } catch (DataWriterException const& e) {
                util::log(e.getContext(), e.getMessage(), LogLevel::Error);
            }
        } else {
            LogError("Error: Cound not find a writer for the specified extension and data type");
        }
    } else if (volumeFile_.get().empty()) {
        LogWarn("Error: Please specify a file to write to");
    } else if (!volume) {
        LogWarn("Error: Please connect a volume to export");
    }
}
Exemplo n.º 8
0
    Utils::Ticket<AudioWorld> AudioWorld::playSound(Handle::SfxHandle h, const Math::float3& position, bool relative, float maxDist)
    {
#ifdef RE_USE_SOUND

        if (!m_Context)
            return Utils::Ticket<AudioWorld>();

        alcMakeContextCurrent(m_Context);

        Sound& snd = m_Allocator.getElement(h);

        // Get a cached source object
        Source s = getFreeSource();

        //LogInfo() << "play sound " << snd.sfx.file << " vol " << snd.sfx.vol;

        alSourcef(s.m_Handle, AL_PITCH, m_Engine.getGameClock().getGameEngineSpeedFactor());
        alSourcef(s.m_Handle, AL_GAIN, snd.sfx.vol / 127.0f);
        alSource3f(s.m_Handle, AL_POSITION, position.x, position.y, position.z);
        alSource3f(s.m_Handle, AL_VELOCITY, 0, 0, 0);
        alSourcef(s.m_Handle, AL_MAX_DISTANCE, maxDist);

        // Relative for sources directly attached to the listener
        alSourcei(s.m_Handle, AL_SOURCE_RELATIVE, relative ? AL_TRUE : AL_FALSE);

        // TODO: proper looping would require slicing and queueing multiple buffers
        // and setting the source to loop when the non-looping buffer was played.
        // start and end don't seem to be used, thoug?
        alSourcei(s.m_Handle, AL_LOOPING, snd.sfx.loop ? AL_TRUE : AL_FALSE);

        alSourcei(s.m_Handle, AL_BUFFER, snd.m_Handle);
        ALenum error = alGetError();
        if (error != AL_NO_ERROR)
        {
            static bool warned = false;
            if (!warned)
            {
                LogWarn() << "Could not attach buffer to source: " << AudioEngine::getErrorString(error);
                warned = true;
            }
            return Utils::Ticket<AudioWorld>();
        }

        alSourcePlay(s.m_Handle);
        error = alGetError();
        if (error != AL_NO_ERROR)
        {
            static bool warned = false;
            if (!warned)
            {
                LogWarn() << "Could not start source!" << AudioEngine::getErrorString(error);
                warned = true;
            }
            return Utils::Ticket<AudioWorld>();
        }
        return s.soundTicket;
#else
        return Utils::Ticket<AudioWorld>();
#endif
    }
Exemplo n.º 9
0
void *Thread::ThreadCall(void *myWrapper)
{
	Wrapper *wrapper = reinterpret_cast<Wrapper*>(myWrapper);
	wrapper->thread->mRunning = true;
	
#ifdef PTW32_STATIC_LIB
	pthread_win32_thread_attach_np();
#endif
	
	try {
		wrapper->call();
	}
	catch(const std::exception &e)
	{
		LogWarn("Thread::ThreadCall", String("Unhandled exception in thread: ") + e.what()); 
	}
	catch(...)
	{
		LogWarn("Thread::ThreadCall", String("Unhandled unknown exception in thread")); 
	}
	
	delete wrapper;
	wrapper->thread->mRunning = false;
	
#ifdef PTW32_STATIC_LIB
	pthread_win32_thread_detach_np();
#endif
	pthread_exit(NULL);
	return NULL;
}
Exemplo n.º 10
0
int setup_ipv6_socket(struct srv_sock_info *ssi)
{
	struct sockaddr_in6 serv6_addr;
	int sd6, opt;

	ssi->sd = -1;

	sd6 = socket(AF_INET6, SOCK_STREAM, 0);
	if (sd6 < 0) {
		LogWarn("Failed IPv6 socket: %s", strerror(errno));
		goto err;
	}

	memset(&serv6_addr, 0, sizeof (serv6_addr));
	serv6_addr.sin6_family = AF_INET6;
	serv6_addr.sin6_port = htons(tcsd_options.port);

	/* If no remote_ops are defined, restrict connections to localhost
	 * only at the socket. */
	if (tcsd_options.remote_ops[0] == 0)
		serv6_addr.sin6_addr = in6addr_loopback;
	else
		serv6_addr.sin6_addr = in6addr_any;

#ifdef __linux__
	/* Linux, by default, allows one socket to be used by both IP stacks
	 * This option disables that behavior, so you must have one socket for
	 * each IP protocol. */
	opt = 1;
	if(setsockopt(sd6, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt)) == -1) {
		LogWarn("Could not set IPv6 socket option properly.\n");
		goto err;
	}
#endif

	opt = 1;
	setsockopt(sd6, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
	if (bind(sd6, (struct sockaddr *) &serv6_addr, sizeof (serv6_addr)) < 0) {
		LogWarn("Failed IPv6 bind: %s", strerror(errno));
		goto err;
	}

	if (listen(sd6, TCSD_MAX_SOCKETS_QUEUED) < 0) {
		LogWarn("Failed IPv6 listen: %s", strerror(errno));
		goto err;
	}

	ssi->domain = AF_INET6;
	ssi->sd = sd6;
	ssi->addr_len = sizeof(serv6_addr);

	return 0;

 err:
	if (sd6 != -1)
		close(sd6);

	return -1;
}
Exemplo n.º 11
0
/**
 * @brief Add a user entry to the cache
 *
 * @note The caller must hold uid2grp_user_lock for write.
 *
 * @param[in] group_data that has supplementary groups allocated
 *
 * @retval true on success.
 * @retval false if our reach exceeds our grasp.
 */
bool uid2grp_add_user(struct group_data *gdata)
{
	struct avltree_node *name_node;
	struct avltree_node *id_node;
	struct avltree_node *name_node2 = NULL;
	struct avltree_node *id_node2 = NULL;
	struct cache_info *info;
	struct cache_info *tmp;

	info = gsh_malloc(sizeof(struct cache_info));
	if (!info) {
		LogEvent(COMPONENT_IDMAPPER, "memory alloc failed");
		return false;
	}
	info->uid = gdata->uid;
	info->uname.addr = gdata->uname.addr;
	info->uname.len = gdata->uname.len;
	info->gdata = gdata;

	/* The refcount on group_data should be 1 when we put it in
	 * AVL trees.
	 */
	uid2grp_hold_group_data(gdata);

	/* We may have lost the race to insert. We remove existing
	 * entry and insert this new entry if so!
	 */
	name_node = avltree_insert(&info->uname_node, &uname_tree);
	if (unlikely(name_node)) {
		tmp = avltree_container_of(name_node,
					   struct cache_info,
					   uname_node);
		uid2grp_remove_user(tmp);
		name_node2 = avltree_insert(&info->uname_node, &uname_tree);
	}

	id_node = avltree_insert(&info->uid_node, &uid_tree);
	if (unlikely(id_node)) {
		/* We should not come here unless someone changed uid of
		 * a user. Remove old entry and re-insert the new
		 * entry.
		 */
		tmp = avltree_container_of(id_node,
					   struct cache_info,
					   uid_node);
		uid2grp_remove_user(tmp);
		id_node2 = avltree_insert(&info->uid_node, &uid_tree);
	}
	uid_grplist_cache[info->uid % id_cache_size] = &info->uid_node;

	if (name_node && id_node)
		LogWarn(COMPONENT_IDMAPPER, "shouldn't happen, internal error");
	if ((name_node && name_node2) || (id_node && id_node2))
		LogWarn(COMPONENT_IDMAPPER, "shouldn't happen, internal error");

	return true;
}
Exemplo n.º 12
0
IW_TELEPHONY_API ApiErrorCode
SubscribeToIncomingCalls(IN LpHandlePtr stackIncomingHandle, IN LpHandlePtr listenerHandle)
{
	FUNCTRACKER;

	MsgCallSubscribeReq *msg = new MsgCallSubscribeReq();
	msg->listener_handle = listenerHandle;

	IwMessagePtr response = NULL_MSG;


	// wait for ok or nack
	ApiErrorCode res = GetCurrRunningContext()->DoRequestResponseTransaction(
		stackIncomingHandle,
		IwMessagePtr(msg),
		response,
		Seconds(5),
		"SubscribeToIncomingCalls TXN");


	if (res == API_TIMEOUT)
	{
		// just to be sure that timeout-ed call
		// eventually gets hanged up
		LogWarn("SubscribeToIncomingCalls - Timeout.");
		return API_TIMEOUT;
	}

	if (IW_FAILURE(res))
	{
		LogWarn("SubscribeToIncomingCalls - failure res:" << res);
		return API_FAILURE;
	}

	switch (response->message_id)
	{
	case MSG_CALL_SUBSCRIBE_ACK:
		{
			res = API_SUCCESS;
			break;
		}
	default:
		{
			res = API_SERVER_FAILURE;
		}
	}


	return res; 

}
Exemplo n.º 13
0
void PyInviwo::addModulePath(const std::string& path) {
    if (!Py_IsInitialized()) {
        LogWarn("addModulePath(): not initialized");
        return;
    }

    std::string pathConv = path;
    replaceInString(pathConv, "\\", "/");
    std::string runString = "import sys\n";
    runString.append(std::string("sys.path.append('") + pathConv + std::string("')"));
    int ret = PyRun_SimpleString(runString.c_str());

    if (ret != 0) LogWarn("Failed to add '" + pathConv + "' to Python module search path");
}
Exemplo n.º 14
0
int setup_ipv4_socket(struct srv_sock_info ssi[])
{
	struct sockaddr_in serv_addr;
	int sd, opt;

	ssi->sd = -1;

	// Initialization of IPv4 socket.
	sd = socket(AF_INET, SOCK_STREAM, 0);
	if (sd < 0) {
		LogWarn("Failed IPv4 socket: %s", strerror(errno));
		goto err;
	}

	memset(&serv_addr, 0, sizeof (serv_addr));
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_port = htons(tcsd_options.port);

	/* If no remote_ops are defined, restrict connections to localhost
	 * only at the socket. */
	if (tcsd_options.remote_ops[0] == 0)
		serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
	else
		serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);

	opt = 1;
	setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
	if (bind(sd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0) {
		LogWarn("Failed IPv4 bind: %s", strerror(errno));
		goto err;
	}

	if (listen(sd, TCSD_MAX_SOCKETS_QUEUED) < 0) {
		LogWarn("Failed IPv4 listen: %s", strerror(errno));
		goto err;
	}

	ssi->domain = AF_INET;
	ssi->sd = sd;
	ssi->addr_len = sizeof(serv_addr);

	return 0;

 err:
	if (sd != -1)
		close(sd);

	return -1;
}
static bool admin_dbus_grace(DBusMessageIter *args,
			      DBusMessage *reply)
{
#define IP_INPUT 120
	char *errormsg = "Started grace period";
	bool success = true;
	DBusMessageIter iter;
        nfs_grace_start_t gsp;
        char buf[IP_INPUT];
        char *input = NULL;
        char *ip;

	dbus_message_iter_init_append(reply, &iter);
	if (args == NULL) {
		errormsg = "Grace period take 1 arguments: event:IP-address.";
		LogWarn(COMPONENT_DBUS, "%s", errormsg);
		success = false;
		goto out;
	}
	if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(args)) {
		errormsg = "Grace period arg 1 not a string.";
		success = false;
		LogWarn(COMPONENT_DBUS, "%s", errormsg);
		goto out;
	}
	dbus_message_iter_get_basic(args, &input);

	gsp.nodeid = -1;
	gsp.event = EVENT_TAKE_IP;

	ip = strstr(input, ":");
	if (ip == NULL)
		gsp.ipaddr = input; /* no event specified */
	else {
		gsp.ipaddr = ip+1;  /* point at the ip passed the : */
		strncpy(buf, input, IP_INPUT);
		ip = strstr(buf, ":");
		if (ip != NULL) {
	                *ip = 0x0;  /* replace ":" with null */
			gsp.event = atoi(buf);
		}
		if (gsp.event == EVENT_TAKE_NODEID)
			gsp.nodeid = atoi(gsp.ipaddr);
	}
	nfs4_start_grace(&gsp);
out:
	dbus_status_reply(&iter, success, errormsg);
	return success;
}
Exemplo n.º 16
0
void Channel::HandleEventWithGuard(Timestamp receive_time) {
  event_handling_ = true;
#if defined(__MACH__) || defined(__ANDROID_API__)
  LogTrace("%s", REventsToString().c_str());
#else
  VLOG(1) << REventsToString();
#endif

  if ((revents_ & POLLHUP) && !(revents_ & POLLIN)) {
    if (log_hup_) {
#if defined(__MACH__) || defined(__ANDROID_API__)
      LogWarn("Channel::handle_event() POLLHUP");
#else
      LOG(WARNING) << "Channel::handle_event() POLLHUP";
#endif
    }

    if (close_callback_) {
      close_callback_();
    }
  }

  if (revents_ & POLLNVAL) {
#if defined(__MACH__) || defined(__ANDROID_API__)
    LogWarn("Channel::handle_event() POLLNVAL");
#else
    LOG(WARNING) << "Channel::handle_event() POLLNVAL";
#endif
  }

  if (revents_ & (POLLERR | POLLNVAL)) {
    if (error_callback_) error_callback_();
  }

#ifndef POLLRDHUP
  const int POLLRDHUP = 0;
#endif

  if (revents_ & (POLLIN | POLLPRI | POLLRDHUP)) {
    if (read_callback_) read_callback_(receive_time);
  }

  if (revents_ & POLLOUT) {
    if (write_callback_) write_callback_();
  }

  event_handling_ = false;
}
Exemplo n.º 17
0
    CacheMonitorServer::CacheMonitorServer()
    : folderCache_(Factory::GetCacheFolder()),
      folderMeta_(Factory::GetMetaFolder()),
      run_(true),
      minFreeSize_(0), maxFreeSize_(0),
      thread_(boost::thread(&CacheMonitorServer::ServerThread,this))
    {
        struct statfs stat;
        if ( 0 != statfs(folderCache_.string().c_str(),&stat) ) {
            LogWarn(folderCache_);
            return;
        }
        off_t sizeFileSystemOnePercent =
                (off_t)stat.f_bsize * stat.f_blocks / 100;

        Configure * config = Factory::GetConfigure();

        minFreeSize_ = config->GetValueSize(Configure::CacheFreeMinSize);
        off_t sizeMinFreePercent = sizeFileSystemOnePercent
                * config->GetValueSize(Configure::CacheFreeMinPercent);
        minFreeSize_ = max(minFreeSize_,sizeMinFreePercent);
        LogDebug(minFreeSize_);

        maxFreeSize_ = config->GetValueSize(Configure::CacheFreeMaxSize);
        off_t sizeMaxFreePercent = sizeFileSystemOnePercent
                * config->GetValueSize(Configure::CacheFreeMaxPercent);
        maxFreeSize_ = max(maxFreeSize_,sizeMaxFreePercent);
        LogDebug(maxFreeSize_);
    }
Exemplo n.º 18
0
bool Store::Sink::push(Fountain::Combination &incoming)
{
	std::unique_lock<std::mutex> lock(mMutex);

	mSink.solve(incoming);
	if(!mSink.isDecoded()) return false;

	BinaryString sinkDigest;
	mSink.hash(sinkDigest);

	LogDebug("Store::push", "Block is complete, digest is " + sinkDigest.toString());

	if(!mDigest.empty() && sinkDigest != mDigest)
	{
		LogWarn("Store::push", "Block digest is invalid (expected " + mDigest.toString() + ")");
		mSink.clear();
		return false;
	}

	mPath = Cache::Instance->path(mDigest);

	File file(mPath, File::Write);
	mSize = mSink.dump(file);
	file.close();
	return true;
}
Exemplo n.º 19
0
int dbus_heartbeat_cb(void *arg)
{
	SetNameFunction("dbus_heartbeat");
	int err = 0;
	int rc = BCAST_STATUS_OK;
	dbus_bool_t ishealthy = get_ganesha_health(&healthstats);

	if (ishealthy) {
		/* send the heartbeat pulse */
		err = gsh_dbus_broadcast(DBUS_PATH HEARTBEAT_NAME,
					 DBUS_ADMIN_IFACE,
					 HEARTBEAT_NAME,
					 DBUS_TYPE_BOOLEAN,
					 &ishealthy,
					 DBUS_TYPE_INVALID);
		if (err) {
			LogCrit(COMPONENT_DBUS,
				"heartbeat broadcast failed. err:%d",
				err);
			rc = BCAST_STATUS_WARN;
		}
	} else
		LogWarn(COMPONENT_DBUS,
			"Health status is unhealthy.  Not sending heartbeat");

	return rc;
}
Exemplo n.º 20
0
/**
 * @brief Concatenate a number of pseudofs tokens into a string
 *
 * When reading pseudofs paths from export entries, we divide the
 * path into tokens. This function will recombine a specific number
 * of those tokens into a string.
 *
 * @param[in/out] fullpseudopath Must be not NULL. Tokens are copied to here.
 * @param[in] node for which a full pseudopath needs to be formed.
 * @param[in] maxlen maximum number of chars to copy to fullpseudopath
 *
 * @return void
 */
void fullpath_h(char *fullpseudopath, pseudofs_entry_t *this_node,
		int *currlen, int maxlen)
{
	if (this_node != &(gPseudoFs.root))
		fullpath_h(fullpseudopath, this_node->parent, currlen, maxlen);

	if (*currlen >= maxlen)
		return;

	if (*currlen + strlen(this_node->name) > maxlen) {
		LogWarn(COMPONENT_NFS_V4_PSEUDO,
			"Pseudopath length is very long, can't"
			" create guaranteed unique handle with this.");
		strncpy(fullpseudopath + (*currlen),
			this_node->name,
			maxlen - *currlen - 1);	/* leave room for \0 */
		*currlen += (maxlen - *currlen - 1);
		fullpseudopath[*currlen] = '\0';
		*currlen = maxlen;
		return;
	}
	strncpy(fullpseudopath + (*currlen),
		this_node->name,
		strlen(this_node->name));
	*currlen += strlen(this_node->name);

	if (*currlen != maxlen && this_node != &(gPseudoFs.root)) {
		fullpseudopath[(*currlen)++] = '/';
		fullpseudopath[*currlen] = '\0';
	} else
		fullpseudopath[*currlen] = '\0';
}
Exemplo n.º 21
0
HelpWidget::HelpWidget(QWidget* parent)
    : InviwoDockWidget(tr("Help"), parent), helpBrowser_(nullptr), helpEngine_(nullptr) {
    setObjectName("HelpWidget");
    setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);

    QWidget* centralWidget = new QWidget();
    QVBoxLayout* vLayout = new QVBoxLayout(centralWidget);
    vLayout->setSpacing(7);
    vLayout->setContentsMargins(0, 0, 0, 0);

    std::string helpfile =
        InviwoApplication::getPtr()->getPath(InviwoApplication::PATH_HELP, "/inviwo.qhc");

    helpEngine_ = new QHelpEngineCore(QString::fromStdString(helpfile), this);

    helpBrowser_ = new HelpBrowser(this, helpEngine_);
    helpBrowser_->setHtml(QString("Hello world"));
    vLayout->addWidget(helpBrowser_);
    centralWidget->setLayout(vLayout);
    setWidget(centralWidget);

    connect(helpEngine_, SIGNAL(setupFinished()), this, SLOT(setupFinished()));

    if (!helpEngine_->setupData()) {
        LogWarn("Faild to setup the help engine:" << helpEngine_->error().toUtf8().constData());
        delete helpEngine_;
        helpEngine_ = nullptr;
    }
}
Exemplo n.º 22
0
Arquivo: events.c Projeto: darylc/fpp
/*
 * Trigger an event
 */
int TriggerEventByID(char *id)
{
	LogDebug(VB_EVENT, "TriggerEventByID(%s)\n", id);

	if (getFPPmode() == MASTER_MODE)
		SendEventPacket(id);

	FPPevent *event = LoadEvent(id);

	if (!event)
	{
		LogWarn(VB_EVENT, "Unable to load event %s\n", id);
		return 0;
	}

	if (event->effect)
		StartEffect(event->effect, event->startChannel);

	if (event->script)
		RunEventScript(event);

	FreeEvent(event);

	return 1;
}
Exemplo n.º 23
0
bool Entity::addComponent( const ComponentPtr& component )
{
	if( !component ) return false;

	Class* type = component->getType();

    if( componentsMap.Find(type) != componentsMap.End() )
	{
        LogWarn( "Component '%s' already exists in '%s'", type->name, name.CString() );
		return false;
	}

	componentsMap[type] = component;
	component->setEntity(this);

	onComponentAdded(component);
	sendEvents();

	if( IsGroup(parent) )
	{
		Group* group = (Group*) parent;
		group->onEntityComponentAdded(component);
	}

    components.Push(component);

	return true;
}
Exemplo n.º 24
0
int TestFuncDebug()
{
	/* log the function entry log. */
	LogFuncEntry();

	LogTrace("Trace log %s %f", "Test", 1.066f);
	LogDebug("Debug level log" );
	LogInfo("Info level log %d" , 0);
	LogWarn("Warn level log" );
	LogError("Error level log" );
	LogFatal("Fatal level log" );

	if(1)
	{
		/* log the function exit. */
		LogFuncExit();
		return 0;
	}
	else
	{
		/* log the function exit. */
		LogFuncExit();
		return -1;
	}
	
}
Exemplo n.º 25
0
    AudioWorld::AudioWorld(Engine::BaseEngine& engine, AudioEngine& audio_engine, const VDFS::FileIndex& vdfidx)
        : m_Engine(engine)
        , m_VDFSIndex(vdfidx)
        , m_exiting(false)
    {
#ifdef RE_USE_SOUND
        if (!audio_engine.getDevice())
            return;

        m_Context = alcCreateContext(audio_engine.getDevice(), nullptr);
        if (!m_Context)
        {
            LogWarn() << "Could not create OpenAL context: "
                      << AudioEngine::getErrorString(alcGetError(audio_engine.getDevice()));
            return;
        }

        alcMakeContextCurrent(m_Context);

        alListener3f(AL_POSITION, 0, 0, 0.0f);
        // check for errors
        alListener3f(AL_VELOCITY, 0, 0, 0);
        // check for errors
        ALfloat listenerOri[] = {0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f};
        alListenerfv(AL_ORIENTATION, listenerOri);

        // Need this for AL_MAX_DISTANCE to work
        alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);

        createSounds();

        initializeMusic();
#endif
    }
Exemplo n.º 26
0
bool PortFactory::registerObject(PortFactoryObject *port) {
    if (!util::insert_unique(map_, port->getClassIdentifier(), port)) {
        LogWarn("Port with class name: " << port->getClassIdentifier() << " already registered");
        return false;
    }
    return true;
}
Exemplo n.º 27
0
object_file_type_t posix2fsal_type(mode_t posix_type_in)
{

	switch (posix_type_in & S_IFMT) {
	case S_IFIFO:
		return FIFO_FILE;

	case S_IFCHR:
		return CHARACTER_FILE;

	case S_IFDIR:
		return DIRECTORY;

	case S_IFBLK:
		return BLOCK_FILE;

	case S_IFREG:
	case S_IFMT:
		return REGULAR_FILE;

	case S_IFLNK:
		return SYMBOLIC_LINK;

	case S_IFSOCK:
		return SOCKET_FILE;

	default:
		LogWarn(COMPONENT_FSAL, "Unknown object type: %d",
			posix_type_in);
		return -1;
	}

}
Exemplo n.º 28
0
void PropertySelectionTreeWidget::addProcessorNetwork(ProcessorNetwork* processorNetwork, std::string workspaceFileName) {
    std::vector<Processor*> processors = processorNetwork->getProcessors();
    QTreeWidgetItem* worksapceItem = new QTreeWidgetItem(QStringList(QString::fromStdString(workspaceFileName)));

    if (processors.size())
        propertySelectionTree_->addTopLevelItem(worksapceItem);
    else {
        LogWarn("Empty workpace with no processors" << workspaceFileName);
        return;
    }

    for (auto& processor : processors) {
        std::vector<Property*> properties = processor->getProperties();
        std::string processorId = processor->getIdentifier();
        QTreeWidgetItem* processorItem = new QTreeWidgetItem(QStringList(QString::fromStdString(processorId)));
        worksapceItem->addChild(processorItem);

        for (auto& propertie : properties) {
            std::string id = propertie->getIdentifier();
            QTreeWidgetItem* newItem = new QTreeWidgetItem(QStringList(QString::fromStdString(id)));
            processorItem->addChild(newItem);
            newItem->setFlags(newItem->flags() | Qt::ItemIsUserCheckable);
            newItem->setCheckState(0, Qt::Unchecked);
        }

        propertySelectionTree_->addTopLevelItem(processorItem);
        processorItem->sortChildren(0, Qt::AscendingOrder);
    }

    propertySelectionTree_->expandAll();
}
Exemplo n.º 29
0
 bool
 FileMetaParser::ParseSwiftMeta(const fs::path & path)
 {
     MetaManager * meta = Factory::GetMetaManager();
     auto_ptr<Inode> inode(meta->GetInode(path));
     if ( inode.get() == NULL ) {
         return false;
     }
     string swiftName = "user.swift.metadata";
     char buffer[1024];
     string swiftContent;
     for (int i=0; true; ++i) {
         string metaName = swiftName;
         if (i != 0) {
             metaName = swiftName + boost::lexical_cast<string>(i);
         }
         int size;
         if (! inode->GetExtendedAttribute(
                 metaName, buffer, sizeof(buffer) - 1, size )) {
             break;
         }
         buffer[size] = '\0';
         swiftContent += buffer;
     }
     try {
         return ParseSwift(swiftContent);
     } catch ( const std::exception & e ) {
         LogWarn("Un-expected exception to parse inode swift meta: "
                 <<  e.what());
         return false;
     }
 }
Exemplo n.º 30
0
/**
 * posix2fsal_type:
 * Convert posix object type to FSAL node type.
 *
 * \param posix_type_in (input):
 *        The POSIX object type.
 *
 * \return - The FSAL node type associated to posix_type_in.
 *         - -1 if the input type is unknown.
 */
fsal_nodetype_t posix2fsal_type(mode_t posix_type_in)
{

  switch (posix_type_in & S_IFMT)
    {
    case S_IFIFO:
      return FSAL_TYPE_FIFO;

    case S_IFCHR:
      return FSAL_TYPE_CHR;

    case S_IFDIR:
      return FSAL_TYPE_DIR;

    case S_IFBLK:
      return FSAL_TYPE_BLK;

    case S_IFREG:
    case S_IFMT:
      return FSAL_TYPE_FILE;

    case S_IFLNK:
      return FSAL_TYPE_LNK;

    case S_IFSOCK:
      return FSAL_TYPE_SOCK;

    default:
      LogWarn(COMPONENT_FSAL, "Unknown object type: %d", posix_type_in);
      return -1;
    }

}