summaryrefslogtreecommitdiffstats
path: root/tools/scripts/check_msword_import.sh
blob: 58475e1e4c1db3c60911b0df207acbf76b33ff23 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
if ! tde-config ; then
  echo 'tde-config not found ! Aborting. You need a more recent KDE, or to fix your $PATH.'
  exit 1
fi
IFS=:

echo -n "KDE prefixes: "
tde-config --prefix

# Check for the binary
found=0
exedirs=`tde-config --path exe`
for dir in $exedirs; do
  if [ -f "$dir/kword" ]; then
    echo "kword found in $dir"
    found=1
  fi
done

if [ $found -eq 0 ]; then
    echo "ERROR: kword not found - looked at $exedirs"
fi

mimelnks=`tde-config --path mime`
# Relevant existing mimetypes
mimes=""

for dir in $mimelnks; do
  filename="application/msword.desktop"
  if [ -f "$dir$filename" ]; then
      echo -n "Found: $dir$filename... "
      hidden=`grep ^Hidden $dir$filename`
      if [ "$hidden" == "true" ]; then
          echo "deleted";
      else
          mimetype=`grep ^MimeType $dir$filename|sed -e 's/.*=//'`
          mimes="$mimes:$mimetype"; # using ':' because of IFS
          patterns=`grep ^Patterns $dir$filename|sed -e 's/.*=//'`
          if [ -n "$patterns" ]; then
              echo -n "(associated with $patterns)"
          fi
          echo
      fi
  fi
  filename="application/msword2.desktop"
  if [ -f "$dir$filename" ]; then
      echo -n "Found: $dir$filename... "
      hidden=`grep ^Hidden $dir$filename`
      if [ "$hidden" == "true" ]; then
          echo "deleted";
      else
          mimetype=`grep ^MimeType $dir$filename|sed -e 's/.*=//'`
          mimes="$mimes:$mimetype"; # using ':' because of IFS
          patterns=`grep ^Patterns $dir$filename|sed -e 's/.*=//'`
          if [ -n "$patterns" ]; then
              echo -n "(associated with $patterns)"
          fi
          echo
      fi
  fi
done

IFS=" "
mimes=`echo $mimes | sed -e 's/^://g'`
echo "Relevant mimetypes found: $mimes"

IFS=:
foundmagicfile=0
for dir in $mimelnks; do
  magic=$dir/magic
  if [ -f "$magic" ]; then
    echo "$magic says: "
    grep 'Microsoft\\ Word' $magic
    foundmagicfile=1
  fi
done

if [ $foundmagicfile -eq 0 ]; then
    echo "ERROR: Magic file not found $magic"
fi

for dir in `tde-config --path services`; do
  echo Services dir $dir
  for mime in $mimes; do
     grep "Import=.*$mime" $dir/*.desktop
  done
done