Jump to content

Recommended Posts

Posted

FARSHAD, please add this feature. I have all the code shown below. Works nice.

I wanted a /d switch to force desktop mode, just like /m forces mobile mode.

I searched and searched and only found one mediocre solution. It required that you change the

   ServerModule.UniServerModule.Options:=serverModule.UniServerModule.Options-[soAutoPlatformSwitch];
   P:=the URL without the /m so that it loads the Desktop version
   UniSession.UrlRedirect(P);

With this logic, it mostly worked, but would hang sometimes. Also, it changes the way the server operates. IE: If ANOTHER user logs in on another session, there would be NO AUTO DETECT FOR THE PLATFORM SWITCH :(

So, i discarded it. Also, there are a number of sites that describe how to get the iPad Safari to force desktop mode. My OLD iPad didn't have the available setting to do that :( AND if it DID work, it would force ALL web sites to use the desktop version. Couldn't make it site specific, like you can in chrome.

The solution needs to EASY and not mess up other web sites... and not hang... and not mess up with the auto platform switching.

SOOOOOooo, i added a new switch. I added the "/d" switch. Much like the /m forces the mobile mode, the /d forces the desktop mode.

THis magic is done in the uniGUIServer.pas file. And inside the GetUniGUISession function.

Add this in vars.

  ForceDeskTop:Boolean; //DLR

Then add the ForceDesktop:=False in between the FServerMonitor and SessionClass initializations.

 

 FServerMonitor := False;
  ForceDeskTop:= False;   // DLR
  SessionClass := TUniGUISession;

Then after the check for the 'server' switch, add the check for the /d switch...
 

        ADoc := uniHTTPDocument(ARequest.Document);
        FServerMonitor := SameText(ADoc, 'server') and FAllowWebMonitor;
        if FServerMonitor then
        begin
          ARequest.Document := '/';
          ADoc := '';
        end;

        {
          DLR - Check for the /D switch
        }
        ForceDeskTop:= SameText(ADoc, 'd');
        if ForceDeskTop then
        begin
          ARequest.Document := '/';
          ADoc := '';
        end;

The final piece of the puzzle is to bypass the auto switch. So, place the new code after setting the ForceMobile variable.
 

          ForceMobile :=
            (not Assigned(MainFormClass[TUniPlatformDesktop])) or
              (
                (soAutoPlatformSwitch in FOptions) and (currPlatform = upMobile)
              );


          {
            DLR Should i get rid of ForceMobile?
          }
          If ForceDeskTop Then
             ForceMobile:=False;

So, essentially, if i find the /d then i ignore the auto switch.

This allows for 3 ways to load the application...

1. somesite.com/mdemo.dll               works for most cases and devices.

2. somesite.com/mdemo.dll/m          allows you to force it show the MOBILE forms

3. somesite.com/mdemo.dll/d           allows you to force it show the DESKTOP forms

 

I know this is not elegant, but gives the "force desktop" capability without messing around with the server options that can affect other sessions. And you don't have to mess around with browser settings. To me this was the best solution.

FARSHAD: Could you please add this /d capability  so that others can also make use of this? 95% of the time the auto works great. But for iPads and tablets that are large enuf, its nice to view the DESKTOP version even though the stupid browser on the device might indicate that it's a mobile device.

Make sense?

 

Thanks

DAvie

 

 

 

 

 

  • Like 1
Posted

Right, when i saw the code, i thought that the server variables were being "copied" from the main global server variables so that it was a per instance copy. But when i started another session from a different browser and saw that the variable had been changed, i was dissapointed.

I saw this post from about 4 years ago... 
 

procedure TMainForm.UniButton1Click(Sender: TObject);
var p:string;

begin
//1. Autoplaform = False
  serverModule.UniServerModule.Options:=[];

//2. parameter p1 for bypassing mobile loginForm
  p:=Unit1.fct_SHA1(DateTimeToStr(Now));
  UniSession.UrlRedirect('http://' + MainModule.MyIP + ':8077/m?p1=' + p);
 //   UniSession.UrlRedirect('http://' + MainModule.MyIP + '/Test/project1.dll/m?p1=' + p);

end;

There was some hardcoding for the domain/MyOP and the fact that the redirect was mostly working but sometimes the browser would just spin and spin. So it wasn't perfect but close.

 

AND the fact that ANY PROJECT that i would work on "might" need these simalar changes to force desktop mode... made me think that life would be so much easier if there was just a simple switch.

Right?

Even if the 4 year old code worked perfect and didn't require HARDCODING, i think it's better to have the /d switch cause it's zero coding for the programmer cause they don't have to modify any of their apps.

 

Thanks

DAvie

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...