Example #1
0
/*
 * i4b_Timeout() watches the DCD signal and mentions it if it's status
 * changes.
 */
static void
i4b_Timeout(void *data)
{
  struct physical *p = data;
  struct i4bdevice *dev = device2i4b(p->handler);
  int ombits, change;

  timer_Stop(&dev->Timer);
  dev->Timer.load = SECTICKS;		/* Once a second please */
  timer_Start(&dev->Timer);
  ombits = dev->mbits;

  if (p->fd >= 0) {
    if (ioctl(p->fd, TIOCMGET, &dev->mbits) < 0) {
      log_Printf(LogPHASE, "%s: ioctl error (%s)!\n", p->link.name,
                 strerror(errno));
      datalink_Down(p->dl, CLOSE_NORMAL);
      timer_Stop(&dev->Timer);
      return;
    }
  } else
    dev->mbits = 0;

  if (ombits == -1) {
    /* First time looking for carrier */
    if (Online(dev))
      log_Printf(LogPHASE, "%s: %s: CD detected\n", p->link.name, p->name.full);
    else if (++dev->carrier_seconds >= dev->dev.cd.delay) {
      log_Printf(LogPHASE, "%s: %s: No carrier"
                 " (increase ``set cd'' from %d ?)\n",
                 p->link.name, p->name.full, dev->dev.cd.delay);
      timer_Stop(&dev->Timer);
      /* i4b_AwaitCarrier() will notice */
    } else {
      /* Keep waiting */
      log_Printf(LogDEBUG, "%s: %s: Still no carrier (%d/%d)\n",
                 p->link.name, p->name.full, dev->carrier_seconds,
                 dev->dev.cd.delay);
      dev->mbits = -1;
    }
  } else {
    change = ombits ^ dev->mbits;
    if (change & TIOCM_CD) {
      if (dev->mbits & TIOCM_CD)
        log_Printf(LogDEBUG, "%s: offline -> online\n", p->link.name);
      else {
        log_Printf(LogDEBUG, "%s: online -> offline\n", p->link.name);
        log_Printf(LogPHASE, "%s: Carrier lost\n", p->link.name);
        datalink_Down(p->dl, CLOSE_NORMAL);
        timer_Stop(&dev->Timer);
      }
    } else
      log_Printf(LogDEBUG, "%s: Still %sline\n", p->link.name,
                 Online(dev) ? "on" : "off");
  }
}
Example #2
0
	void OnUserPostNick(User* user, const std::string& oldnick) override
	{
		// Detect and ignore nickname case change
		if (ServerInstance->FindNickOnly(oldnick) == user)
			return;

		Offline(user, oldnick);
		Online(user);
	}
Example #3
0
static const char *
i4b_OpenInfo(struct physical *p)
{
  struct i4bdevice *dev = device2i4b(p->handler);
  static char buf[26];

  if (Online(dev))
    snprintf(buf, sizeof buf, "carrier took %ds", dev->carrier_seconds);
  else
    *buf = '\0';

  return buf;
}
Example #4
0
static void
i4b_Offline(struct physical *p)
{
  struct i4bdevice *dev = device2i4b(p->handler);

  if (p->fd >= 0) {
    timer_Stop(&dev->Timer);
    if (Online(dev)) {
      int dummy;

      dummy = 1;
      ioctl(p->fd, TIOCCDTR, &dummy);
    }
  }
}
Example #5
0
static int
i4b_AwaitCarrier(struct physical *p)
{
  struct i4bdevice *dev = device2i4b(p->handler);

  if (dev->mbits == -1) {
    if (dev->Timer.state == TIMER_STOPPED) {
      dev->carrier_seconds = 0;
      i4b_StartTimer(p);
    }
    return CARRIER_PENDING;			/* Not yet ! */
  }

  return Online(dev) ? CARRIER_OK : CARRIER_LOST;
}
Example #6
0
bool ModuleManager::FitModule(InventoryItemRef item, EVEItemFlags flag)
{
    if(item->categoryID() == EVEDB::invCategories::Module)
    {
        // Attempt to fit the module
        if( _fitModule(item, flag) )
        {
            // Now that module is successfully fitted, attempt to put it Online:
            Online(item->itemID());
            return true;
        }
    }
    else
        SysLog::Debug("ModuleManager","%s tried to fit item %u, which is not a module", m_Ship->GetOperator()->GetName(), item->itemID());

    return false;
}
NG_LoopBackNetworkDeviceInterface::NG_LoopBackNetworkDeviceInterface()
{
	m_currentQueue=0;
	Online();   // LoopBackdevices are 'online' immediately
}
Example #8
0
bool CUserPageBuilder::Build(CWholePage* pWholePage)
{
	// introducing the players - these will point to the XML objects required
	// to construct a user page
	CPageUI			Interface(m_InputContext);
	CUser*			pViewer = NULL;
	CUser			Owner(m_InputContext);
	CGuideEntry		Masthead(m_InputContext);
	CForum			PageForum(m_InputContext);
	CForum			Journal(m_InputContext);
	CPostList		RecentPosts(m_InputContext);
	CArticleList	RecentArticles(m_InputContext);
	CArticleList	RecentApprovals(m_InputContext);
	CCommentsList	RecentComments(m_InputContext);
	CArticleSubscriptionList	SubscribedUsersArticles(m_InputContext);
	
	CTDVString	sSecretKey;
	int			iSecretKey = 0;
	int			iUserID = 0;		// the user ID in the URL
	bool		bRegistering = false;
	bool		bSuccess = true;	// our success flag

	// get the user ID from the URL => zero if not present
	// TODO: something appropriate if no ID provided	
	iUserID = m_InputContext.GetParamInt("UserID");
	// now get the secret key if there is one
	// we may need to process it so get it as a string
	if (m_InputContext.GetParamString("Key", sSecretKey))
	{
		// if the secret key start with "3D" we must strip this off
		// - it is caused by a mime encoding problem, 3D is the ascii hex for =
		if (sSecretKey.Find("3D") == 0)
		{
			sSecretKey =  sSecretKey.Mid(2);
		}
		iSecretKey = atoi(sSecretKey);
		if (iSecretKey > 0)
		{
			// if there is a secret key then it is a registration attempt
			bRegistering = true;
		}
	}
	// now give appropriate page depending on whether this is a registration or not
	if (bRegistering)
	{
//		CStoredProcedure* pSP = m_InputContext.CreateStoredProcedureObject();
		CTDVString sPageContent = "";
		CTDVString sPageSubject = "";
//		CTDVString sCookie;

		// check we got our SP okay
//		if (pSP == NULL)
//		{
//			bSuccess = false;
//		}
		// if so then call the activate user method, which should return us a nice
		// warm cookie if all goes well
//		if (bSuccess)
//		{
//			bSuccess = pSP->ActivateUser(iUserID, iSecretKey, &sCookie);
			// make sure cookie is not empty
//			if (sCookie.IsEmpty())
//			{
//				bSuccess = false;
//			}
//		}
		// if okay then build page with the cookie in and a message to the user
		if (bSuccess)
		{
			// we have a cookie and we are prepared to use it
			// TODO: what about the MEMORY tag?
			// TODO: put this in stylesheet? Deal with delayed refresh?
//			CTDVString sCookieXML = "<SETCOOKIE><COOKIE>" + sCookie + "</COOKIE></SETCOOKIE>";

//			sPageSubject = "Registration in process ...";
//			sPageContent << "<GUIDE><BODY>";
//			sPageContent << "<P>Thank you for registering as an official Researcher for The Hitch Hiker's ";
//			sPageContent << "Guide to the Galaxy: we do hope you enjoy contributing to the Guide.</P>";
//			sPageContent << "<P>Please wait while you are transferred to <LINK BIO=\"U" << iUserID << "\">";
//			sPageContent << "your Personal Home Page</LINK> ... or click the link if nothing happens.</P>";
//			sPageContent << "</BODY></GUIDE>";
//			pWholePage = CreateSimplePage(sPageSubject, sPageContent);
//			if (pWholePage == NULL)
//			{
//				bSuccess = false;
//			}

			if (bSuccess)
			{
				bSuccess = InitPage(pWholePage, "USERPAGE",false);
			}
			// put the cookie xml inside the H2G2 tag
//			bSuccess = pWholePage->AddInside("H2G2", sCookieXML);

//			CTDVString sUserXML = "";
//			sUserXML << "<REGISTERING-USER>";
//			sUserXML << "<USER>";
//			sUserXML << "<USERNAME></USERNAME>";
//			sUserXML << "<USERID>" << iUserID << "</USERID>";
//			sUserXML << "</USER>";
//			sUserXML << "</REGISTERING-USER>";
//			bSuccess = pWholePage->AddInside("H2G2", sUserXML);
//			bSuccess = bSuccess && pWholePage->SetPageType("REGISTER-CONFIRMATION");

		CTDVString sRedirect;
		sRedirect << "ShowTerms" << iUserID;
		sRedirect << "?key=" << sSecretKey;
		pWholePage->Redirect(sRedirect);
		}
		else
		{
			sPageSubject = "Sorry ...";
			sPageContent << "<GUIDE><BODY>";
			sPageContent << "<P>The URL you've given is wrong. Please re-check your email, or <LINK HREF=\"/Register\">click here to re-enter your email address</LINK>.</P>";
			sPageContent << "</BODY></GUIDE>";
			bSuccess = CreateSimplePage(pWholePage, sPageSubject, sPageContent);
		}
		// make sure we delete the SP if any
//		delete pSP;
//		pSP = NULL;
	}
	else
	{
		// get or create all the appropriate xml objects
		pViewer		= m_InputContext.GetCurrentUser();
		bool bGotMasthead = false; 
		bool bGotPageForum = false; 
		bool bGotJournal = false; 
		bool bGotRecentPosts = false; 
		bool bGotRecentArticles = false; 
		bool bGotRecentApprovals = false; 
		bool bGotRecentComments = false; 
		bool bGotSubscribedToUsersRecentArticles = false; 

		bool bGotOwner		= CreatePageOwner(iUserID, Owner);

		CreatePageTemplate(pWholePage);
		if (m_InputContext.IncludeUsersGuideEntryInPersonalSpace() || (m_InputContext.GetParamInt("i_uge") == 1) ||
			m_InputContext.IncludeUsersGuideEntryForumInPersonalSpace() || (m_InputContext.GetParamInt("i_ugef") == 1))
		{
			bGotMasthead = CreatePageArticle(iUserID, Owner, Masthead);

			if (m_InputContext.IncludeUsersGuideEntryForumInPersonalSpace() || (m_InputContext.GetParamInt("i_ugef") == 1))
			{
				// GuideEntry forum can not be returned if GuideEntry is not being returned.
				bGotPageForum = CreatePageForum(pViewer, Masthead, PageForum);
			}
		}

		bool bGotInterface = CreateUserInterface(pViewer, Owner, Masthead, Interface);
		
		// Only display other information if the page has a valid masthead
		if (bGotMasthead)
		{
			if (m_InputContext.IncludeJournalInPersonalSpace() || (m_InputContext.GetParamInt("i_j") == 1))
			{
				bGotJournal = CreateJournal(Owner, pViewer, Journal);
			}

			if (m_InputContext.IncludeRecentPostsInPersonalSpace() || (m_InputContext.GetParamInt("i_rp") == 1))
			{
				bGotRecentPosts = CreateRecentPosts(Owner, pViewer, RecentPosts);
			}

			if (m_InputContext.IncludeRecentCommentsInPersonalSpace() || (m_InputContext.GetParamInt("i_rc") == 1))
			{
				bGotRecentComments = CreateRecentComments(Owner, pViewer, RecentComments);
			}

			if (m_InputContext.IncludeRecentGuideEntriesInPersonalSpace() || (m_InputContext.GetParamInt("i_rge") == 1))
			{
				bGotRecentArticles = CreateRecentArticles(Owner, RecentArticles);
				bGotRecentApprovals = CreateRecentApprovedArticles(Owner, RecentApprovals);
			}

			if (m_InputContext.IncludeUploadsInPersonalSpace() || (m_InputContext.GetParamInt("i_u") == 1))
			{
				CTDVString sUploadsXML;
				CUpload Upload(m_InputContext);
				Upload.GetUploadsForUser(iUserID,sUploadsXML);
				pWholePage->AddInside("H2G2",sUploadsXML);
			}

			if (m_InputContext.IncludeRecentArticlesOfSubscribedToUsersInPersonalSpace() || (m_InputContext.GetParamInt("i_rasu") == 1))
			{
				bGotSubscribedToUsersRecentArticles = CreateSubscribedToUsersRecentArticles(Owner, m_InputContext.GetSiteID(), SubscribedUsersArticles); 
			}
		}

		// See if the user wants to swap to this site and change their masthead and journal (if it exists)
/*
	This feature is now redundant. There's no concept of a homesite.
		if (m_InputContext.ParamExists("homesite"))
		{
			if (pViewer == NULL)
			{
				// error: Not registered - ignore request
			}
			else if (!bGotOwner)
			{
				// error - no actual owner, ignore request
			}
			else if (pViewer->GetIsEditor())
			{
				int iCurrentSiteID = m_InputContext.GetSiteID();
				int iThisSite = iCurrentSiteID;
				if (bGotMasthead)
				{
					iCurrentSiteID = Masthead.GetSiteID();
				}
				if ( iThisSite != iCurrentSiteID && m_InputContext.CanUserMoveToSite(iCurrentSiteID, iThisSite))
				{
					CStoredProcedure SP;
					m_InputContext.InitialiseStoredProcedureObject(&SP);
					if (bGotMasthead)
					{
						SP.MoveArticleToSite(Masthead.GetH2G2ID(), m_InputContext.GetSiteID());
						//delete pMasthead;
						Masthead.Destroy();
						bGotMasthead = CreatePageArticle(iUserID, Owner, Masthead);
					}
					int iJournal;
					Owner.GetJournal(&iJournal);
					if (iJournal > 0)
					{
						SP.MoveForumToSite(iJournal, m_InputContext.GetSiteID());
					}

					int iPrivateForum;
					if (Owner.GetPrivateForum(&iPrivateForum))
					{
						SP.MoveForumToSite(iPrivateForum, m_InputContext.GetSiteID());
					}
					pWholePage->AddInside("H2G2", "<SITEMOVED RESULT='success'/>");
				}
			}
		}
*/
		// check that all the *required* objects have been created successfully
		// note that pViewer can be NULL if an unregistered viewer
		// pOwner can be NULL if we are serving a default page because this user ID
		// does not exist
		// bGotJournal can be false if the user doesn't exist, or has no journal
		// bGotRecentPosts can be false if the user doesn't exist
		// pRecentArticles can be NULL if the user doesn't exist
		// pRecentApprovals can be NULL if the user doesn't exist
		// bGotPageForum can be false if there is no masthead, or if it has no forum yet
		// pMasthead could be NULL if the user has not created one yet
		if (pWholePage->IsEmpty() || bGotInterface == false)
		{
			bSuccess = false;
		}
		// now add all the various subcomponents into the whole page xml
		// add owner of page
		if (bSuccess)
		{
			// if we have a page owner then put their details in, otherwise make
			// up a pretend user from the ID we were given
			if (bGotOwner)
			{
				bSuccess = pWholePage->AddInside("PAGE-OWNER", &Owner);
			}
			else
			{
				CTDVString sPretendUserXML = "";
				sPretendUserXML << "<USER><USERID>" << iUserID << "</USERID>";
				sPretendUserXML << "<USERNAME>Researcher " << iUserID << "</USERNAME></USER>";
				bSuccess = pWholePage->AddInside("PAGE-OWNER", sPretendUserXML);
			}
		}
		// there should always be an interface but check anyway
		if (bSuccess && bGotInterface)
		{
			bSuccess = pWholePage->AddInside("H2G2", &Interface);
		}
		if (bSuccess && m_InputContext.ParamExists("clip"))
		{
			CTDVString sSubject;
			if (bGotOwner)
			{
				Owner.GetUsername(sSubject);
			}
			else
			{
				sSubject << "U" << iUserID;
			}

			bool bPrivate = m_InputContext.GetParamInt("private") > 0;
			CLink Link(m_InputContext);
			if ( Link.ClipPageToUserPage("userpage", iUserID, sSubject, NULL, pViewer, bPrivate) )
				pWholePage->AddInside("H2G2", &Link);
		}
		// if masthead NULL stylesheet should do the default response
		if (bSuccess && bGotMasthead && (m_InputContext.IncludeUsersGuideEntryInPersonalSpace() || (m_InputContext.GetParamInt("i_uge") == 1)))
		{
			bSuccess = pWholePage->AddInside("H2G2", &Masthead);
		}
		// add page forum if there is one => this is the forum associated with
		// the guide enty that is the masthead for this user
		if (bSuccess && bGotPageForum && (m_InputContext.IncludeUsersGuideEntryForumInPersonalSpace() || (m_InputContext.GetParamInt("i_ugef") == 1)))
		{
			bSuccess = pWholePage->AddInside("H2G2", &PageForum);
		}
		// add journal if it exists
		if (bSuccess && bGotJournal)
		{
			bSuccess = pWholePage->AddInside("JOURNAL", &Journal);
		}
		// add recent posts if they exist, this may add an empty
		// POST-LIST tag if the user exists but has never posted
		if (bSuccess && bGotRecentPosts)
		{
			bSuccess = pWholePage->AddInside("RECENT-POSTS", &RecentPosts);
		}
		// add recent articles if they exist, this may add an empty
		// ARTICLES-LIST tag if the user exists but has never written a guide entry
		if (bSuccess && bGotRecentArticles)
		{
			bSuccess = pWholePage->AddInside("RECENT-ENTRIES", &RecentArticles);
			// add the user XML for the owner too
			if (bGotOwner)
			{
				bSuccess = bSuccess && pWholePage->AddInside("RECENT-ENTRIES", &Owner);
			}
		}
		// add recent articles if they exist, this may add an empty
		// ARTICLES-LIST tag if the user exists but has never had an entry approved
		if (bSuccess && bGotRecentApprovals)
		{
			bSuccess = pWholePage->AddInside("RECENT-APPROVALS", &RecentApprovals);
			// add the user XML for the owner too
			if (bGotOwner)
			{
				bSuccess = bSuccess && pWholePage->AddInside("RECENT-APPROVALS", &Owner);
			}
		}
		// add recent comments if they exist, this may add an empty
		// COMMENTS-LIST tag if the user exists but has never posted
		if (bSuccess && bGotRecentComments)
		{
			bSuccess = pWholePage->AddInside("RECENT-COMMENTS", &RecentComments);
		}

		if (bSuccess && bGotSubscribedToUsersRecentArticles)
		{
			bSuccess = pWholePage->AddInside("RECENT-SUBSCRIBEDARTICLES", &SubscribedUsersArticles);
		}

		CTDVString sSiteXML;
		m_InputContext.GetSiteListAsXML(&sSiteXML);
		bSuccess = bSuccess && pWholePage->AddInside("H2G2", sSiteXML);

		if (bGotMasthead && (m_InputContext.IncludeWatchInfoInPersonalSpace() || (m_InputContext.GetParamInt("i_wi") == 1)))
		{
			CWatchList WatchList(m_InputContext);
			bSuccess = bSuccess && WatchList.Initialise(iUserID);
			bSuccess = bSuccess && pWholePage->AddInside("H2G2",&WatchList);
			int iSiteID = m_InputContext.GetSiteID();
			bSuccess = bSuccess && WatchList.WatchingUsers(iUserID, iSiteID);
			bSuccess = bSuccess && pWholePage->AddInside("H2G2",&WatchList);
		}

		CWhosOnlineObject Online(m_InputContext);
		bSuccess = bSuccess && Online.Initialise(NULL, 1, true);
		bSuccess = bSuccess && pWholePage->AddInside("H2G2", &Online);

		if (bGotMasthead && (m_InputContext.IncludeClubsInPersonalSpace() || (m_InputContext.GetParamInt("i_c") == 1)))
		{
			if (pViewer != NULL && pViewer->GetUserID() == iUserID) 
			{
				CClub Club(m_InputContext);
				Club.GetUserActionList(iUserID, 0, 20);
				pWholePage->AddInside("H2G2", &Club);
			}

			// Now add all the clubs the user belongs to
			CCurrentClubs Clubs(m_InputContext);
			if (bSuccess && Clubs.CreateList(iUserID,true))
			{
				bSuccess = pWholePage->AddInside("H2G2",&Clubs);
			}
		}
		
		if (bGotMasthead && bSuccess && (m_InputContext.IncludePrivateForumsInPersonalSpace() || (m_InputContext.GetParamInt("i_pf") == 1)))
		{
			pWholePage->AddInside("H2G2", "<PRIVATEFORUM/>");
			CForum Forum(m_InputContext);
			int iPrivateForum = 0;
			if (bGotOwner)
			{
				Owner.GetPrivateForum(&iPrivateForum);
			}
			Forum.GetThreadList(pViewer, iPrivateForum, 10,0);
			pWholePage->AddInside("PRIVATEFORUM", &Forum);

			// Now check to see if the user has alerts set for their private forum
			if (bGotOwner)
			{
				CEmailAlertList Alert(m_InputContext);
				Alert.GetUserEMailAlertSubscriptionForForumAndThreads(iUserID,iPrivateForum);
				pWholePage->AddInside("PRIVATEFORUM", &Alert);
			}
		}

		if (bGotMasthead && bSuccess && (m_InputContext.IncludeLinksInPersonalSpace() || (m_InputContext.GetParamInt("i_l") == 1)))
		{
			CTDVString sLinkGroup;
			m_InputContext.GetParamString("linkgroup", sLinkGroup);
			if (bGotOwner && pViewer != NULL && Owner.GetUserID() == pViewer->GetUserID()) 
			{
				ManageClippedLinks(pWholePage);
			}
			if (bGotOwner)
			{
				CLink Link(m_InputContext);
				bool bShowPrivate = (pViewer != NULL && Owner.GetUserID() == pViewer->GetUserID());
				Link.GetUserLinks(Owner.GetUserID(), sLinkGroup, bShowPrivate);
				pWholePage->AddInside("H2G2", &Link);
				Link.GetUserLinkGroups(Owner.GetUserID());
				pWholePage->AddInside("H2G2", &Link);
			}
		}

		if (bGotMasthead && m_InputContext.IncludeTaggedNodesInPersonalSpace() || (m_InputContext.GetParamInt("i_tn") == 1))
		{
			//Get the Users Crumtrail - all the nodes + ancestors the user is tagged to .
			CCategory CCat(m_InputContext);
			if ( bSuccess && CCat.GetUserCrumbTrail(Owner.GetUserID()) )
			{
				bSuccess = pWholePage->AddInside("H2G2",&CCat);
			}
		}

		if (bSuccess && bGotMasthead)
		{
			CTDVString sPostCodeXML;
			CTDVString sNoticeXML;
			if (m_InputContext.IncludeNoticeboardInPersonalSpace() || (m_InputContext.GetParamInt("i_n") == 1) ||
				m_InputContext.IncludePostcoderInPersonalSpace() || (m_InputContext.GetParamInt("i_p") == 1))
			{
				if (pViewer != NULL)
				{
					// Insert the notice board information!
					CTDVString sPostCodeToFind;
					if(pViewer->GetPostcode(sPostCodeToFind))
					{
						int iSiteID = m_InputContext.GetSiteID();
						CNotice Notice(m_InputContext);
						if (!Notice.GetLocalNoticeBoardForPostCode(sPostCodeToFind,iSiteID,sNoticeXML,sPostCodeXML))
						{
							sNoticeXML << "<NOTICEBOARD><ERROR>FailedToFindLocalNoticeBoard</ERROR></NOTICEBOARD>";
						}
					}
					else
					{
						//if the user has not entered a postcode then flag an Notice Board error
						sNoticeXML << "<NOTICEBOARD><ERROR>UserNotEnteredPostCode</ERROR></NOTICEBOARD>";
					}
				}
				else
				{
					sNoticeXML << "<NOTICEBOARD><ERROR>UserNotLoggedIn</ERROR></NOTICEBOARD>";
				}

				if (m_InputContext.IncludeNoticeboardInPersonalSpace() || (m_InputContext.GetParamInt("i_n") == 1))
				{
					bSuccess = pWholePage->AddInside("H2G2",sNoticeXML);
				}
			}

			if (m_InputContext.IncludePostcoderInPersonalSpace() || (m_InputContext.GetParamInt("i_p") == 1))
			{
				// Insert the postcoder if it's not empty
				if (bSuccess && !sPostCodeXML.IsEmpty())
				{
					bSuccess = bSuccess && pWholePage->AddInside("H2G2",sPostCodeXML);
				}
			}
		}

		if (m_InputContext.IncludeSiteOptionsInPersonalSpace() || (m_InputContext.GetParamInt("i_so") == 1))
		{
			// Return SiteOption SystemMessageOn if set. 
			if (bSuccess && m_InputContext.IsSystemMessagesOn(m_InputContext.GetSiteID()))
			{
				CTDVString sSiteOptionSystemMessageXML = "<SITEOPTION><NAME>UseSystemMessages</NAME><VALUE>1</VALUE></SITEOPTION>"; 

				bSuccess = bSuccess && pWholePage->AddInside("H2G2",sSiteOptionSystemMessageXML);
			}
		}
		
/*
		Mark Howitt 11/8/05 - Removing the civic data from the user page as it is nolonger used by any sites.
							  The only place civic data is used now is on the postcoder page.

		//include civic data
		if (bSuccess)
		{
			if ( m_InputContext.GetSiteID( ) == 16 )
			{
				CTDVString sActualPostCode;				
				bool bFoundLocalInfo = false;
				// First check to see if there is a postcode in the URL
				if (m_InputContext.ParamExists("postcode"))
				{
					// Get the postcode and use this to display the noticeboard
					if (m_InputContext.GetParamString("postcode", sActualPostCode))
					{
						//dont do any validations
						bFoundLocalInfo = true;				
					}
				}

				//next if no postcode variable is included in URL
				//or if the specified postcode value is invalid 
				//or if the specified postcode value has no entries on the db				
				if (!bFoundLocalInfo)
				{
					// No postcode given, try to get the viewing users postcode if we have one.
					if (pViewer)
					{
						if (pViewer->GetPostcode(sActualPostCode))
						{
							if ( sActualPostCode.IsEmpty( ) == false)
							{
								//dont do any validations
								bFoundLocalInfo = true;
							}
						}							
					}
					else
					{
						//try session cookie, if any 
						CTDVString sPostCodeToFind;
						CPostcoder postcoder(m_InputContext);
						CTDVString sActualPostCode = postcoder.GetPostcodeFromCookie();
						if ( !sActualPostCode.IsEmpty() )
						{
							//dont do any validations
							bFoundLocalInfo = true;
						}
					}
				}

				if ( bFoundLocalInfo )
				{
					if (!sActualPostCode.IsEmpty())
					{
						bool bHitPostcode = false;
						CPostcoder cPostcoder(m_InputContext);
						cPostcoder.MakePlaceRequest(sActualPostCode, bHitPostcode);
						if (bHitPostcode)
						{
							CTDVString sXML = "<CIVICDATA POSTCODE='";
							sXML << sActualPostCode << "'/>";
							pWholePage->AddInside("H2G2", sXML);
							bSuccess = pWholePage->AddInside("CIVICDATA",&cPostcoder);
						}
					}
				}
			}
		}
*/
	}

	return bSuccess;
}
Example #9
0
ModuleManager::ModuleManager(Ship *const ship)
{
    // Create ModuleContainer object and initialize with sizes for all slot banks for this ship:
    m_Modules = new ModuleContainer((uint32)ship->GetAttribute(AttrLowSlots).get_int(),
                                    (uint32)ship->GetAttribute(AttrMedSlots).get_int(),
                                    (uint32)ship->GetAttribute(AttrHiSlots).get_int(),
                                    (uint32)ship->GetAttribute(AttrRigSlots).get_int(),
                                    (uint32)ship->GetAttribute(AttrSubSystemSlot).get_int(),
                                    (uint32)ship->GetAttribute(AttrTurretSlotsLeft).get_int(),
                                    (uint32)ship->GetAttribute(AttrLauncherSlotsLeft).get_int(),
                                    this);

    // Store reference to the Ship object to which the ModuleManager belongs:
    m_Ship = ship;

	// Initialize the log file for this Module Manager instance
	std::string logsubdirectory = "ModuleManagers";
	//std::string logfilename = "On_Ship_" + m_Ship->itemName();		// This method using ship's name string may NOT be path friendly as players naming ships may use path-unfriendly characters - need function to convert to path-friendly ship name string

	std::string logfilename = "On_Ship_" + m_Ship->itemName() + "_(" + std::string(itoa(m_Ship->itemID())) + ")";

	m_pLog = new Task_Log( EVEServerConfig::files.logDir, logsubdirectory, logfilename );

	m_pLog->InitializeLogging( EVEServerConfig::files.logDir, logsubdirectory, logfilename );

    // Load modules, rigs and subsystems from Ship's inventory into ModuleContainer:
	m_pLog->Log("ModuleManager", "Loading modules...");
    uint32 flagIndex;
    for(flagIndex=flagLowSlot0; flagIndex<=flagLowSlot7; flagIndex++)
    {
        InventoryItemRef moduleRef;
		InventoryItemRef chargeRef;
		std::vector<InventoryItemRef>::iterator cur, end;
        std::vector<InventoryItemRef> items;
		m_Ship->FindByFlag( (EVEItemFlags)flagIndex, items );        // Operator assumed to be Client *
		cur = items.begin();
		end = items.end();
		if( items.size() > 0 )
		{
			while( (cur != end) ) {
				if( cur->get()->categoryID() == EVEDB::invCategories::Charge )
					chargeRef = (*cur);
				if( cur->get()->categoryID() == EVEDB::invCategories::Module )
					moduleRef = (*cur);
				cur++;
			}
			if( moduleRef )
			{
				if( _fitModule( moduleRef, (EVEItemFlags)flagIndex ) )
				{
					//_fitModule( moduleRef, (EVEItemFlags)flagIndex );
					if( moduleRef->GetAttribute(AttrIsOnline).get_int() == 1 )
						Online(moduleRef->itemID());
					else
						Offline(moduleRef->itemID());
					if( chargeRef )
						((ActiveModule *)GetModule((EVEItemFlags)flagIndex))->load(chargeRef);
				}
				else
				{
					SysLog::Error( "ModuleManager::ModuleManager()", "ERROR: Cannot fit Low Slot module '%s' (id %u)", moduleRef->itemName().c_str(), moduleRef->itemID() );
					throw PyException( MakeCustomError( "ERROR! Cannot fit Low Slot module '%s'", moduleRef->itemName().c_str() ) );
				}
			}
		}
    }

    for(flagIndex=flagMedSlot0; flagIndex<=flagMedSlot7; flagIndex++)
    {
        InventoryItemRef moduleRef;
		InventoryItemRef chargeRef;
		std::vector<InventoryItemRef>::iterator cur, end;
        std::vector<InventoryItemRef> items;
		m_Ship->FindByFlag( (EVEItemFlags)flagIndex, items );        // Operator assumed to be Client *
		cur = items.begin();
		end = items.end();
		if( items.size() > 0 )
		{
			while( (cur != end) ) {
				if( cur->get()->categoryID() == EVEDB::invCategories::Charge )
					chargeRef = (*cur);
				if( cur->get()->categoryID() == EVEDB::invCategories::Module )
					moduleRef = (*cur);
				cur++;
			}
			if( moduleRef )
			{
				if( _fitModule( moduleRef, (EVEItemFlags)flagIndex ) )
				{
					//_fitModule( moduleRef, (EVEItemFlags)flagIndex );
					if( moduleRef->GetAttribute(AttrIsOnline).get_int() == 1 )
						Online(moduleRef->itemID());
					else
						Offline(moduleRef->itemID());
					if( chargeRef )
						((ActiveModule *)GetModule((EVEItemFlags)flagIndex))->load(chargeRef);
				}
				else
				{
					SysLog::Error( "ModuleManager::ModuleManager()", "ERROR: Cannot fit Med Slot module '%s' (id %u)", moduleRef->itemName().c_str(), moduleRef->itemID() );
					throw PyException( MakeCustomError( "ERROR! Cannot fit Med Slot module '%s'", moduleRef->itemName().c_str() ) );
				}
			}
		}
    }

    for(flagIndex=flagHiSlot0; flagIndex<=flagHiSlot7; flagIndex++)
    {
        InventoryItemRef moduleRef;
		InventoryItemRef chargeRef;
		std::vector<InventoryItemRef>::iterator cur, end;
        std::vector<InventoryItemRef> items;
		m_Ship->FindByFlag( (EVEItemFlags)flagIndex, items );        // Operator assumed to be Client *
		cur = items.begin();
		end = items.end();
		if( items.size() > 0 )
		{
			while( (cur != end) ) {
				if( cur->get()->categoryID() == EVEDB::invCategories::Charge )
					chargeRef = (*cur);
				if( cur->get()->categoryID() == EVEDB::invCategories::Module )
					moduleRef = (*cur);
				cur++;
			}
			if( moduleRef )
			{
				if( _fitModule( moduleRef, (EVEItemFlags)flagIndex ) )
				{
					if( moduleRef->GetAttribute(AttrIsOnline).get_int() == 1 )
						Online(moduleRef->itemID());
					else
						Offline(moduleRef->itemID());
					if( chargeRef )
						((ActiveModule *)GetModule((EVEItemFlags)flagIndex))->load(chargeRef);
				}
				else
				{
					SysLog::Error( "ModuleManager::ModuleManager()", "ERROR: Cannot fit High Slot module '%s' (id %u)", moduleRef->itemName().c_str(), moduleRef->itemID() );
					throw PyException( MakeCustomError( "ERROR! Cannot fit High Slot module '%s'", moduleRef->itemName().c_str() ) );
				}
			}
		}
    }

    for(flagIndex=flagRigSlot0; flagIndex<=flagRigSlot7; flagIndex++)
    {
        InventoryItemRef itemRef;
		std::vector<InventoryItemRef>::iterator cur, end;
        std::vector<InventoryItemRef> items;
		m_Ship->FindByFlag( (EVEItemFlags)flagIndex, items );        // Operator assumed to be Client *
		cur = items.begin();
		end = items.end();
		if( items.size() > 0 )
		{
			while( (cur->get()->categoryID() != EVEDB::invCategories::Module) && (cur != end) ) {
				cur++;
			}
			if( cur->get()->categoryID() == EVEDB::invCategories::Module )
				itemRef = (*cur);
			if( itemRef )
			{
				_fitModule( itemRef, (EVEItemFlags)flagIndex );
				// We don't think Rigs need the Online attribute set, but keep this code here in case we do:
				//if( itemRef->GetAttribute(AttrIsOnline).get_int() == 1 )
				//	Online(itemRef->itemID());
				//else
				//	Offline(itemRef->itemID());
			}
		}
    }

    for(flagIndex=flagSubSystem0; flagIndex<=flagSubSystem7; flagIndex++)
    {
        InventoryItemRef itemRef;
		std::vector<InventoryItemRef>::iterator cur, end;
        std::vector<InventoryItemRef> items;
		m_Ship->FindByFlag( (EVEItemFlags)flagIndex, items );        // Operator assumed to be Client *
		cur = items.begin();
		end = items.end();
		if( items.size() > 0 )
		{
			while( (cur->get()->categoryID() != EVEDB::invCategories::Module) && (cur != end) ) {
				cur++;
			}
			if( cur->get()->categoryID() == EVEDB::invCategories::Module )
				itemRef = (*cur);
			if( itemRef )
			{
				_fitModule( itemRef, (EVEItemFlags)flagIndex );
				// We don't think Subsystems need the Online attribute set, but keep this code here in case we do:
				//if( itemRef->GetAttribute(AttrIsOnline).get_int() == 1 )
				//	Online(itemRef->itemID());
				//else
				//	Offline(itemRef->itemID());
			}
		}
    }

	m_pLog->Log("ModuleManager", "Module loading complete!");

}
Example #10
0
	void OnPostConnect(User* user) override
	{
		Online(user);
	}