bool Surface::createDFBSubSurfaceStereo(const Rectangle& geometry, IDirectFBSurface* parent, int zIndex) { release(); DFBRectangle r = geometry.dfbRect(); _parentSurface = parent; r.x += zIndex; DFBResult ret = _parentSurface->GetSubSurface(_parentSurface, &r, &_dfbSurface); if (ret) { ILOG_ERROR( ILX_SURFACE, "Cannot get sub-surface left: %s", DirectFBErrorString(ret)); return false; } ret = _dfbSurface->SetBlittingFlags(_dfbSurface, DSBLIT_BLEND_ALPHACHANNEL); _dfbSurface->SetStereoEye(_dfbSurface, DSSE_LEFT); r.x -= zIndex + zIndex; ret = _parentSurface->GetSubSurface(_parentSurface, &r, &_rightSurface); if (ret) { ILOG_ERROR( ILX_SURFACE, "Cannot get sub-surface right: %s", DirectFBErrorString(ret)); return false; } ret = _rightSurface->SetBlittingFlags(_rightSurface, DSBLIT_BLEND_ALPHACHANNEL); _rightSurface->SetStereoEye(_rightSurface, DSSE_RIGHT); return true; }
int MGuiHawk::Create(ubus_context *ubus, HawkScreen* hawk) { int ret; ILOG_TRACE_F(MGUI_HAWK); if (_instance) { ILOG_ERROR(MGUI_HAWK, "Already created\n"); return -1; } _instance = new MGuiHawk(ubus, hawk); _instance->SetVersion(); ret = _instance->Register(); if (ret) { ILOG_ERROR(MGUI_HAWK, "Register failed (ret=%d)\n", ret); goto out_error; } ILOG_DEBUG(MGUI_HAWK, "%s exit\n", __FUNCTION__); return 0; out_error: delete _instance; _instance = NULL; }
int MGuiHawk::Register() { int ret; ILOG_TRACE(MGUI_HAWK); ret = UBusClient::Register(hawk_indication, HAWK_UBUS_ID); if (ret) { ILOG_ERROR(MGUI_HAWK, "Register failed %d\n", ret); return ret; } ret = UBusClient::Subscribe(); if (ret) { ILOG_ERROR(MGUI_HAWK, "Subscribe events failed %d\n", ret); goto unregister; } _request = new HawkRequest(_subscriber, _id, _ubus); ILOG_DEBUG(MGUI_HAWK, "%s exit\n", __FUNCTION__); return 0; unregister: UBusClient::UnRegister(); return ret; }
int UBusRequest::InvokeAsync(const char *method, blob_attr *b) { ubus_request *req; int ret = 0; ILOG_TRACE(UBUS_REQ); ILOG_DEBUG(UBUS_REQ, "%s enter\n", __func__); req = (ubus_request *)malloc(sizeof(*req)); if (!req) { ILOG_ERROR(UBUS_REQ,"memory allocation failed\n"); return -1; } ret = ubus_invoke_async(_ubus, _id, method, b, req); if (ret) { ILOG_ERROR(UBUS_REQ, "ubus_invoke failed [id=%d, method=%s, err=%s]\n", _id, method, ubus_strerror(ret)); free(req); return ret; } ILOG_DEBUG(UBUS_REQ,"ubus_invoke_async done [id=%d, method=%s]\n", _id, method); req->data_cb = data_cb; req->complete_cb = complete_cb; req->priv = this; ubus_complete_request_async(_ubus, req); ILOG_DEBUG(UBUS_REQ, "ubus_complete_request_async done\n"); return 0; }
void MGuiHawk::ForceUpload() { ILOG_ERROR(MGUI_HAWK, "%s: _request=%p\n", __FUNCTION__, _request); if (_instance) { ILOG_ERROR(MGUI_HAWK, "%s: _request=%p\n", __FUNCTION__, _request); _request->Request(HawkForceUploadReq); } }
void Surface::setGeometry(int x, int y, int width, int height) { ILOG_TRACE(ILX_SURFACE); DFBRectangle r = { x, y, width, height }; if (_parentSurface) { DFBResult ret = _dfbSurface->MakeSubSurface(_dfbSurface, _parentSurface, &r); if (ret) ILOG_ERROR(ILX_SURFACE, "Cannot set geometry: %s\n", DirectFBErrorString(ret)); } else ILOG_ERROR(ILX_SURFACE, "Cannot set geometry without a parent surface!\n"); }
void Surface::flip() { ILOG_TRACE(ILX_SURFACE); DFBResult ret; switch (PlatformManager::instance().getLayerFlipMode(_owner->_rootWindow->layerName())) { case FlipNone: ILOG_DEBUG(ILX_SURFACE, " -> Flip using DSFLIP_NONE\n"); ret = _dfbSurface->Flip(_dfbSurface, NULL, DSFLIP_NONE); break; case FlipOnSync: ILOG_DEBUG(ILX_SURFACE, " -> Flip using DSFLIP_ONSYNC\n"); ret = _dfbSurface->Flip(_dfbSurface, NULL, DSFLIP_ONSYNC); break; case FlipWaitForSync: ILOG_DEBUG(ILX_SURFACE, " -> Flip using DSFLIP_WAITFORSYNC\n"); ret = _dfbSurface->Flip(_dfbSurface, NULL, DSFLIP_WAITFORSYNC); break; case FlipNew: ILOG_DEBUG(ILX_SURFACE, " -> Flip using DSFLIP_ONSYNC\n"); ret = _dfbSurface->Flip(_dfbSurface, NULL, DSFLIP_ONSYNC); break; default: ILOG_DEBUG(ILX_SURFACE, " -> Flip using DSFLIP_NONE\n"); ret = _dfbSurface->Flip(_dfbSurface, NULL, DSFLIP_NONE); break; } if (ret) ILOG_ERROR(ILX_SURFACE, " -> Flip error: %s\n", DirectFBErrorString(ret)); }
DFBResult DaleDFB::getCompComp() { if (!__coma) return DFB_FAILURE; if (!__compComp) { static bool tryOnce = true; if (tryOnce) { tryOnce = false; DirectResult ret = __coma->GetComponent(__coma, "Compositor", 500, &__compComp); if (ret) { ILOG_ERROR( ILX_DALEDFB, "Cannot get Compositor component!\n"); return DFB_FAILURE; } __compComp->Listen(__compComp, Compositor::NotificationAck, notificationListener, NULL); } else return DFB_FAILURE; } return DFB_OK; }
bool Surface::createDFBSurface(int width, int height, DFBSurfaceCapabilities caps) { ILOG_TRACE(ILX_SURFACE); release(); DFBSurfaceDescription desc; desc.flags = (DFBSurfaceDescriptionFlags) (DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS); desc.width = width; desc.height = height; desc.pixelformat = PlatformManager::instance().forcedPixelFormat(); if(_flags & ForceSingleSurface) desc.caps = caps; else desc.caps = (DFBSurfaceCapabilities) (caps | PlatformManager::instance().getWindowSurfaceCaps()); desc.hints = DSHF_FONT; DFBResult ret = PlatformManager::instance().getDFB()->CreateSurface(PlatformManager::instance().getDFB(), &desc, &_dfbSurface); if (ret) { ILOG_ERROR(ILX_SURFACE, "Cannot create surface: %s\n", DirectFBErrorString(ret)); return false; } _dfbSurface->SetBlittingFlags(_dfbSurface, DSBLIT_BLEND_ALPHACHANNEL); ILOG_DEBUG(ILX_SURFACE, "[%p] %s(width %d, height %d)\n", this, __FUNCTION__, width, height); ILOG_DEBUG(ILX_SURFACE, " -> Created dfb surface %p\n", _dfbSurface); return true; }
void MGuiHawk::KeepAlive() { if (_instance) { ILOG_ERROR(MGUI_HAWK, "%s: _request=%p\n", __FUNCTION__, _request); _request->Request(HawkKeepAliveReq); } }
void MGuiHawk::Assert() { if (_instance) { ILOG_ERROR(MGUI_HAWK, "%s: _request=%p\n", __FUNCTION__, _request); _request->Request(HawkNoDataAssertReq); } }
void Surface::unlock() { ILOG_TRACE(ILX_SURFACE); int rc = pthread_mutex_unlock(&_surfaceLock); if (rc != 0) ILOG_ERROR(ILX_SURFACE, "Error while unlocking surface!\n"); }
void Surface::setStereoGeometry(int x, int y, int width, int height, int zIndex) { DFBRectangle r = { x, y, width, height }; if (_parentSurface) { r.x += zIndex; DFBResult ret = _dfbSurface->MakeSubSurface(_dfbSurface, _parentSurface, &r); if (ret) ILOG_ERROR( ILX_SURFACE, "Cannot set left geometry: %s\n", DirectFBErrorString(ret)); r.x -= zIndex + zIndex; ret = _rightSurface->MakeSubSurface(_rightSurface, _parentSurface, &r); if (ret) ILOG_ERROR( ILX_SURFACE, "Cannot set right geometry: %s\n", DirectFBErrorString(ret)); } else ILOG_ERROR(ILX_SURFACE, "No Parent Surface, need to create surface again!\n"); }
void AppCompositor::onWindowConfig(DFBWindowID windowID, const SaWManWindowReconfig *reconfig) { ILOG_TRACE_W(ILX_APPCOMPOSITOR); for (WidgetList::iterator it = _children.begin(); it != _children.end(); ++it) { SurfaceView* view = dynamic_cast<SurfaceView*>(*it); if (view && view->dfbWindowID() == windowID) { ILOG_DEBUG(ILX_APPCOMPOSITOR, " -> windowID[%u] Flags[0x%02x]\n", view->dfbWindowID(), reconfig->flags); if (reconfig->flags & SWMCF_STACKING) { if (reconfig->request.association) { ILOG_ERROR(ILX_APPCOMPOSITOR, "Not yet implemented!\n"); } else { if (reconfig->request.opacity == 1) { ILOG_DEBUG(ILX_APPCOMPOSITOR, " -> LowerToBottom\n"); lowerChild(view); view->update(); } else { ILOG_DEBUG(ILX_APPCOMPOSITOR, " -> RaiseToTop\n"); raiseChild(view); view->update(); } sigRestacked(); } } else { if (reconfig->flags & SWMCF_OPACITY) { ILOG_DEBUG(ILX_APPCOMPOSITOR, " -> opacity(%d)\n", reconfig->request.opacity); view->setOpacity(reconfig->request.opacity); view->update(); } if (reconfig->flags & SWMCF_POSITION) { ILOG_DEBUG( ILX_APPCOMPOSITOR, " -> moveTo(%d, %d)\n", reconfig->request.bounds.x, reconfig->request.bounds.y); view->moveTo(reconfig->request.bounds.x * _hScale, reconfig->request.bounds.y * _vScale); view->update(); } if (reconfig->flags & SWMCF_SIZE) { ILOG_DEBUG( ILX_APPCOMPOSITOR, " -> setSize(%d, %d)\n", reconfig->request.bounds.w, reconfig->request.bounds.h); view->setSize(reconfig->request.bounds.w * _hScale, reconfig->request.bounds.h * _vScale); view->update(); } } return; } } }
int RilSimcard::Callback(ubus_request *req, blob_attr *msg) { ILOG_TRACE(MGUI_SIMCARD); if(!req || !msg) { ILOG_ERROR(MGUI_SIMCARD, "request or message is NULL! (req=%p, msg=%p)", req, msg); return -1; } return MGuiRil::Instance()->SimCallback(msg); }
int RilOperator::Callback(ubus_request *req, blob_attr *msg) { ILOG_TRACE(MGUI_OPERATOR); if(!req || !msg) { ILOG_ERROR(MGUI_OPERATOR, "request or message is NULL! (req=%p, msg=%p)", req, msg); return -1; } return MGuiRil::Instance()->OperatorCallback(msg); }
int RilRegistration::Callback(ubus_request *req, blob_attr *msg) { ILOG_TRACE(MGUI_REGISTRATION); if(!req || !msg) { ILOG_ERROR(MGUI_REGISTRATION, "request or msg is NULL (req=%p, msg=%p)\n", req, msg); return -1; } return MGuiRil::Instance()->RegistrationCallback(msg); }
int RilRequest::Request(uint32_t id, const void *data, int len) { int ret = 0; ILOG_TRACE(MGUI_RILREQ); ret = rilutil_makeRequestBlob(&_b, id, data, len); if (ret) { ILOG_ERROR(MGUI_RILREQ, "rilutil_makeRequestBlob failed (ret=%d)\n", ret); return ret; } ret = InvokeAsync(RIL_UBUS_REQ, _b.head); if (ret) { ILOG_ERROR(MGUI_RILREQ, "Invoke() failed (ret=%d)\n", ret); return ret; } ILOG_DEBUG(MGUI_RILREQ, "%s exit\n", __FUNCTION__); return ret; }
void Surface::clear() { ILOG_TRACE(ILX_SURFACE); DFBResult ret = _dfbSurface->Clear(_dfbSurface, 0, 0, 0, 0); if (ret) ILOG_ERROR(ILX_SURFACE, "Clear error: %s\n", DirectFBErrorString(ret)); else ILOG_DEBUG(ILX_SURFACE, " -> Cleared surface.\n"); }
void Surface::flipStereo(const Rectangle& left, const Rectangle& right) { DFBRegion l = left.dfbRegion(); DFBRegion r = right.dfbRegion(); ILOG_DEBUG(ILX_SURFACE, "[%p] %s Left(%d,%d,%d,%d) Right(%d,%d,%d,%d)\n", this, __FUNCTION__, left.x(), left.y(), left.width(), left.height(), right.x(), right.y(), right.width(), right.height()); DFBResult ret = _dfbSurface->FlipStereo(_dfbSurface, &l, &r, DSFLIP_WAITFORSYNC); if (ret) ILOG_ERROR(ILX_SURFACE, "Flip error: %s\n", DirectFBErrorString(ret)); }
DFBSurfaceID Surface::dfbSurfaceId() const { unsigned int id = 0; #if ILIXI_DFB_SURFACE_EVENTS if (_dfbSurface) _dfbSurface->GetID(_dfbSurface, &id); else #endif ILOG_ERROR(ILX_SURFACE, "Cannot get surface id!\n"); return id; }
static int hawk_indication(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { MGuiHawk *__this = MGuiHawk::Instance(); if (!__this) { ILOG_ERROR(MGUI_HAWK, "No instance, indication ignored!\n"); return -1; } return __this->Indication(ctx, obj, req, method, msg); }
bool XMLReader::loadFile(const std::string& file, int parserOptions) { ILOG_TRACE_F(ILX_XMLREADER); release(); ILOG_DEBUG(ILX_XMLREADER, " -> file: %s\n", file.c_str()); _ctxt = xmlNewParserCtxt(); if (_ctxt == NULL) { ILOG_ERROR(ILX_XMLREADER, "Failed to allocate parser context!\n"); return false; } #ifdef ANDROID_NDK _doc = xmlCtxtReadFile(_ctxt, file.c_str(), NULL, XML_PARSE_RECOVER | XML_PARSE_NOENT | XML_PARSE_NOBLANKS); #else _doc = xmlCtxtReadFile(_ctxt, file.c_str(), NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT | XML_PARSE_DTDVALID | XML_PARSE_NOBLANKS); #endif if (_doc == NULL) { xmlFreeParserCtxt(_ctxt); _ctxt = NULL; ILOG_ERROR(ILX_XMLREADER, "Failed to parse %s!\n", file.c_str()); return false; } if ((parserOptions & XML_PARSE_DTDVALID) && (_ctxt->valid == 0)) { xmlFreeDoc(_doc); xmlFreeParserCtxt(_ctxt); _doc = NULL; _ctxt = NULL; ILOG_ERROR(ILX_XMLREADER, "Failed to validate %s!\n", file.c_str()); return false; } _currentNode = root()->xmlChildrenNode; ILOG_DEBUG(ILX_XMLREADER, " -> done.\n"); return true; }
int UBusSubscriber::UnSubscribe(std::string &event) { uint32_t id; int ret; ILOG_TRACE(UBUS_SUBSCRIBER); if (ubus_lookup_id(_ubus, event.c_str(), &id)) { ILOG_ERROR(UBUS_SUBSCRIBER, "ubus lookup id %s failed\n", event.c_str()); return -1; } ret = ubus_unsubscribe(_ubus, &_subscriber, id); if (ret) { ILOG_ERROR(UBUS_SUBSCRIBER,"event %s unsubscribe failed (err: %s)\n", event.c_str(), ubus_strerror(ret)); return ret; } ILOG_DEBUG(UBUS_SUBSCRIBER, "unsubscribe event %s success\n", event.c_str()); return 0; }
DFBResult DaleDFB::comaGetComponent(const char* name, IComaComponent** component) { ILOG_TRACE_F(ILX_DALEDFB); if (!__coma) return DFB_FAILURE; if (__coma->GetComponent(__coma, name, 500, component) != DR_OK) { ILOG_ERROR( ILX_DALEDFB, "%s( %s ) failed!\n", __FUNCTION__, name); return DFB_FAILURE; } return DFB_OK; }
DFBResult DaleDFB::comaGetLocal(unsigned int bytes, void** ret) { ILOG_TRACE_F(ILX_DALEDFB); if (!__coma) return DFB_FAILURE; if (__coma->GetLocal(__coma, bytes, ret) != DR_OK) { ILOG_ERROR( ILX_DALEDFB, "%s( %u ) failed!\n", __FUNCTION__, bytes); return DFB_FAILURE; } return DFB_OK; }
bool Surface::createDFBSubSurface(const Rectangle& geometry, IDirectFBSurface* parent) { ILOG_TRACE(ILX_SURFACE); release(); DFBRectangle r = geometry.dfbRect(); _parentSurface = parent; DFBResult ret = _parentSurface->GetSubSurface(_parentSurface, &r, &_dfbSurface); if (ret) { ILOG_ERROR(ILX_SURFACE, "Cannot get sub-surface: %s", DirectFBErrorString(ret)); return false; } ret = _dfbSurface->SetBlittingFlags(_dfbSurface, DSBLIT_BLEND_ALPHACHANNEL); if (ret) { ILOG_ERROR(ILX_SURFACE, "Cannot set blitting flags of sub-surface: %s", DirectFBErrorString(ret)); return false; } ILOG_DEBUG(ILX_SURFACE, "[%p] %s(x %d, y %d, w %d, h %d, parent %p)\n", this, __FUNCTION__, geometry.x(), geometry.y(), geometry.width(), geometry.height(), parent); ILOG_DEBUG(ILX_SURFACE, " -> Created dfb surface %p\n", _dfbSurface); return true; }
int RilRegistration::Request() { int ret; ILOG_TRACE(MGUI_REGISTRATION); ILOG_DEBUG(MGUI_REGISTRATION, "Request voice registration\n"); ret = RilRequest::Request(RIL_REQUEST_VOICE_REGISTRATION_STATE); if (ret) { ILOG_ERROR(MGUI_RILREQ, "request voice registration failed (ret=%d)\n", ret); return ret; } ILOG_DEBUG(MGUI_REGISTRATION, "Request data registration\n"); ret = RilRequest::Request(RIL_REQUEST_DATA_REGISTRATION_STATE); if (ret) { ILOG_ERROR(MGUI_REGISTRATION, "request voice registration failed (ret=%d)\n", ret); return ret; } ILOG_DEBUG(MGUI_REGISTRATION, "%s:%d: Exit\n", __FUNCTION__, __LINE__); return 0; }
std::string MGuiHawk::GetVersion() { std::string line; std::ifstream mversion("/etc/mversion"); if (mversion.is_open()) { getline(mversion, line); mversion.close(); } else { ILOG_ERROR(MGUI_HAWK, "can't open /etc/mversion\n"); line.assign("ERROR"); } return line; }
DFBResult DaleDFB::comaCallComponent(IComaComponent* component, ComaMethodID method, void* arg) { ILOG_TRACE_F(ILX_DALEDFB); if (!__coma) return DFB_FAILURE; if (component) { int ret_val; if (component->Call(component, method, arg, &ret_val) != DR_OK) { ILOG_ERROR( ILX_DALEDFB, "%s( %lu ) failed!\n", __FUNCTION__, method); return DFB_FAILURE; } return DFB_OK; } return DFB_FAILURE; }