summaryrefslogtreecommitdiffstats
path: root/redhat/kdebase/kdebase-3.5.13-fix_fqdn_in_title.patch
blob: 74122ec465550661bbbc1697c24a2eba6cef1d7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
commit d409abdbef8dd8b72bb2f311fcaa7456bdc2404b
Author: Luboš Luňák <l.lunak@suse.cz>
Date:   Fri Mar 4 16:22:23 2011 +0100

    do not show hostname in titlebar if it's FQDN of localhost

diff --git a/kwin/utils.cpp b/kwin/utils.cpp
--- a/kwin/utils.cpp
+++ b/kwin/utils.cpp
@@ -18,6 +18,8 @@
 #include "utils.h"
 
 #include <unistd.h>
+#include <string.h>
+#include <netdb.h>
 
 #ifndef KCMRULES
 
@@ -323,6 +325,27 @@ bool isLocalMachine( const TQCString& host )
             if( host == hostnamebuf )
                 return true;
             }
+        else
+            { // e.g. LibreOffice likes to give FQDN, even if gethostname() doesn't include domain
+            struct addrinfo hints, *res, *addr;
+            bool is_local = false;
+
+            memset (&hints, 0, sizeof (hints));
+            hints.ai_family = PF_UNSPEC;
+            hints.ai_socktype = SOCK_STREAM;
+            hints.ai_flags |= AI_CANONNAME;
+
+            if( getaddrinfo( host, NULL, &hints, &res ) != 0)
+                return false;
+            for(addr = res; !is_local && addr; addr = addr->ai_next)
+                {
+                if( res->ai_canonname &&
+                    host == TQCString( res->ai_canonname ))
+                    is_local = true;
+                }
+            freeaddrinfo(res);
+            return is_local;
+            }
         }
     return false;
     }